# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443459 | 2021-07-10T14:15:56 Z | urd05 | Distributing Candies (IOI21_candies) | C++17 | 788 ms | 9284 KB |
#include "candies.h" #include <bits/stdc++.h> using namespace std; vector<int> vec; vector<int> distribute_candies(vector<int> c,vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); vec.resize(n); for(int i=0;i<n;i++) { vec[i]=0; } int q=v.size(); int sq=450; for(int i=0;i<q;i+=sq) { int lq=i; int rq=min(i+sq-1,q-1); vector<int> lr; lr.push_back(0); lr.push_back(n); for(int j=lq;j<=rq;j++) { lr.push_back(l[j]); lr.push_back(r[j]+1); } sort(lr.begin(),lr.end()); lr.erase(unique(lr.begin(),lr.end()),lr.end()); for(int j=0;j+1<lr.size();j++) { int del=0; int ube=c[0]; int umax=c[0]; int dbe=0; int dmin=0; for(int k=lq;k<=rq;k++) { if (l[k]<=lr[j]&&r[k]>=lr[j+1]-1) { del+=v[k]; umax=min(umax,c[0]-del); dmin=max(dmin,-del); ube+=v[k]; dbe+=v[k]; ube=max(0,ube); ube=min(c[0],ube); dbe=max(0,dbe); dbe=min(c[0],dbe); } } for(int k=lr[j];k<lr[j+1];k++) { if (vec[k]<=dmin) { vec[k]=dbe; } else if (vec[k]>=umax) { vec[k]=ube; } else { vec[k]+=del; } } } } return vec; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 788 ms | 8124 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 556 ms | 5020 KB | Output is correct |
3 | Correct | 65 ms | 4532 KB | Output is correct |
4 | Correct | 771 ms | 8244 KB | Output is correct |
5 | Correct | 782 ms | 9284 KB | Output is correct |
6 | Correct | 739 ms | 9200 KB | Output is correct |
7 | Correct | 735 ms | 9120 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |