# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
570931 | 2022-05-31T14:47:59 Z | sff_user | Distributing Candies (IOI21_candies) | C++17 | 5000 ms | 17004 KB |
#include <vector> #include<bits/stdc++.h> using namespace std; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); vector<int> s(n,0); int q=l.size(); bool yes=true; for(int i = 0 ; i < q ; i++){ if(v[i]<0){ yes=false;break; } } if(!yes){ for(int i = 0 ; i < q ; i++){ for(int j = l[i] ; j <= r[i] ; j ++){ if(v[i] > 0) s[j] = min(c[j],s[j]+v[i]); else s[j] = max(0,s[j]+v[i]); } } return s; } vector<int> not_F; for(int i = 0 ;i < n ; i++) not_F.push_back(i); for(int i = 0 ; i < q ; i++){ int li=0,ri=not_F.size(),mid1,mid2; while(li <= ri){ mid1=(ri+li)/2; if(not_F[mid1] >= l[i]){ ri= mid1-1; } else{ li=mid1+1; } } li=0,ri=not_F.size(); while(li <= ri){ mid2=(ri+li)/2; if(not_F[mid2] <= r[i]){ li= mid2+1; } else{ ri=mid2-1; } } for(int j = mid1;j<=mid2;j++){ s[j] = min(c[j],s[j]+v[i]); if(s[j]==c[j]) not_F.erase(not_F.begin()+j); } } return s; } /*vector<int> distribute_candies1(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); vector<int> s(n,0); int q=l.size(); for(int i = 0 ; i < q ; i++){ for(int j = l[i] ; j <= r[i] ; j ++){ if(v[i] > 0) s[j] = min(c[j],s[j]+v[i]); else s[j] = max(0,s[j]+v[i]); } } return s; } int main(){ int n,q; cin >> n >> q; vector<int>c(n),l(q),r(q),v(q); for(int i = 0 ; i < n ; i++) cin >> c[i]; for(int i = 0 ; i < q ; i++) cin >> l[i]; for(int i = 0 ; i < q ; i++) cin >> r[i]; for(int i = 0 ; i < q ; i++) cin >> v[i]; vector<int> cc = distribute_candies2(c,l,r,v); cout <<"daz"<<endl; for(int c:cc)cout<<c<<" "; cout << endl; vector<int> cc2 = distribute_candies1(c,l,r,v); for(int c:cc2)cout<<c<<" "; }*/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 995 ms | 17004 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 174 ms | 5028 KB | Output is correct |
3 | Correct | 164 ms | 3836 KB | Output is correct |
4 | Execution timed out | 5016 ms | 7276 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 492 ms | 5024 KB | Output is correct |
4 | Correct | 488 ms | 2800 KB | Output is correct |
5 | Execution timed out | 5100 ms | 7272 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |