http://codeforces.me/contest/825/submission/28650576
Thanks in advance!
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
http://codeforces.me/contest/825/submission/28650576
Thanks in advance!
Hi! I attempted to do the problem http://codeforces.me/problemset/problem/808/C but got a runtime error with my solution saying that the "Exit code is -1073741819".Please can someone tell me what did I do wrong?
Here is my code:
using namespace std; int cmpfunc (const void * a, const void * b) { return ( (int)a — (int)b ); } int main(){ int cap,n,w,sum=0; cin>>n>>w; map <int,int> arr; map<int,int> :: iterator it; int p[n]; for(int i=0;i<n;i++){ cin>>cap; arr.insert(pair<int,int> (cap,i));
p[i]=ceil(cap/2.0); sum+=p[i];
} if(sum>w){ cout<<"-1"; } else { w=w-sum; it=arr.end(); for(;it!=arr.begin();it--){ if(w!=0){ if(w>=it->first/2){ p[it->second]=it->first; w-= (it->first-p[it->second]); } else { p[it->second]+=w; w=0; }
} else { break; } } for(int i=0;i<n;i++){ cout<<p[i]<<" "; }
} return 0; }
Name |
---|