求助,蒟蒻全WA~~

P1090 [NOIP2004 提高组] 合并果子 / [USACO06NOV] Fence Repair G

~~可能是正反错误吧~~ 我也是一个萌新
by RosieFog @ 2020-11-06 21:02:38


@[十月雪](/user/236416) s没有初始化 考场上千万别错了
by 小小小朋友 @ 2020-11-06 21:02:42


``` #include<bits/stdc++.h> using namespace std; int main() { priority_queue<int,vector<int>,greater<int> >q; int a,s=0,n; cin>>n; for(int i=1;i<=n;i++){ cin>>a; q.push(a); } for(int i=1;i<n;i++){ a=q.top(); q.pop(); a+=q.top(); q.pop(); s+=a; q.push(a); } cout<<s<<endl; return 0; } ``` 全AC,s要初始化
by する @ 2020-11-06 21:03:38


哦,谢谢大佬
by _stOrz_ @ 2020-11-06 21:03:53


~~我在这查了半天才看见s没初始化~~ ~~这种错误考场上别犯额~~
by tjhdyhj @ 2020-11-06 21:04:47


|