# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058652 | 2024-08-14T11:45:46 Z | qwusha | Distributing Candies (IOI21_candies) | C++17 | 61 ms | 9040 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second typedef long double ld; const ld eps = 1e-8; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const ll inf = 1e18; const ll mod = 1e9 + 7; #include "candies.h" vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { ll n = c.size(); int q = l.size(); vector<int> res(n); if (n <= 2000 && q <= 2000) { for (int qw = 0; qw < l.size(); qw++) { for (int i = l[qw]; i <= r[qw]; i++) { if (v[qw] > 0) { res[i] = min(res[i] + v[qw], c[i]); } else { res[i] = max(res[i] + v[qw], 0); } } } return res; } vector<ll> pref(n + 1); for (int qw = 0; qw < q; qw++) { pref[l[qw]] += v[qw]; pref[r[qw] + 1] -= v[qw]; } for (int i = 1; i < n; i++) { pref[i] += pref[i - 1]; } for (int i = 0; i < n; i++) { res[i] = min((ll)c[i], pref[i]); } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 8936 KB | Output is correct |
2 | Correct | 53 ms | 9040 KB | Output is correct |
3 | Correct | 60 ms | 8908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 32 ms | 5112 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 25 ms | 5120 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 61 ms | 8936 KB | Output is correct |
7 | Correct | 53 ms | 9040 KB | Output is correct |
8 | Correct | 60 ms | 8908 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Incorrect | 32 ms | 5112 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |