# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
625315 | 2022-08-10T03:16:33 Z | il9 | Distributing Candies (IOI21_candies) | C++17 | 121 ms | 12112 KB |
#include <bits/stdc++.h> using namespace std; vector<int> distribute_candies(vector<int> c, vector<int > l, vector<int> r, vector<int> v) { vector<long long> pre(c.size()+2); pre[0]=0; int n=c.size(); for(int i=0;i<r.size()-1;i++) { pre[l[i]+1]+=v[i]; pre[r[i]+2]-=v[i]; } for(int i=1;i<=n;i++) { pre[i]+=pre[i-1]; //cout<<pre[i]<<" "; } for(int i=0;i<n;i++) { if(pre[i+1]>c[i]) { pre[i+1]=c[i]; } } for(int i=l[r.size()-1];i<=r[r.size()-1];i++) { long long zero=0; long long one=1; pre[i+1]=max(min(pre[i+1]+v[r.size()-1],c[i]*one),zero); } vector<int> ans(n); for(int i=0;i<n;i++) { ans[i]=pre[i+1]; //cout<<pre[i+1]<<" "; } //cout<<"\n"; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 121 ms | 8808 KB | Output is correct |
2 | Correct | 94 ms | 12112 KB | Output is correct |
3 | Correct | 94 ms | 12032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |