# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443455 | 2021-07-10T14:11:29 Z | urd05 | Distributing Candies (IOI21_candies) | C++17 | 99 ms | 14772 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())); 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+=del; dbe+=del; 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 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 99 ms | 14772 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 460 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |