# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436579 | 2021-06-24T16:13:25 Z | shrimb | Distributing Candies (IOI21_candies) | C++17 | 125 ms | 8036 KB |
#include"bits/stdc++.h" // #define int long long #define endl '\n' using namespace std; vector<int> distribute_candies (vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); int q = l.size(); bool st1 = (n <= 2000 and q <= 2000); bool st2 = 1; for (int i = 0 ; i < q ; i++) if (v[i] < 0) st2 = 0; if (st1) { vector<int> ret(n, 0); for (int i = 0 ; i < q ; i++) { for (int j = l[i] ; j <= r[i] ; j++) { ret[j] = max(0, min(c[j], ret[j] + v[i])); } } return ret; } if (st2) { vector<int> ret(n, 0); vector<int> pref(n + 1, 0); for (int i = 0 ; i < q ; i++) { pref[l[i]] += v[i]; pref[r[i] + 1] -= v[i]; } for (int i = 1 ; i < n ; i++) pref[i] += pref[i-1]; for (int i = 0 ; i < n ; i++) ret[i] = min(c[i], pref[i]); return ret; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 3 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 125 ms | 8036 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 | Incorrect | 63 ms | 4952 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 78 ms | 4956 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 3 ms | 332 KB | Output is correct |
6 | Incorrect | 125 ms | 8036 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |