#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = sz(c), q = sz(l);
vector<int> ans(n);
if(n == -1 and q <= 2000) {
for(int Q = 0; Q < q; Q++) {
for(int i = l[Q]; i <= r[Q]; i++)
ans[i] = min(max(0, ans[i] + v[Q]), c[i]);
}
}
else {
vector<ll> p(n+1);
for(int Q = 0; Q < q; Q++) {
p[l[Q]] += v[Q];
p[r[Q]+1] -= v[Q];
}
for(int i = 0; i < n; i++) {
if(i > 0) p[i] += p[i-1];
ans[i] = min((ll)c[i], p[i]);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
8952 KB |
Output is correct |
2 |
Correct |
56 ms |
8896 KB |
Output is correct |
3 |
Correct |
58 ms |
9048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |