#include "candies.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n=c.size(), m=l.size();
vi ch(m);
vvi addOp(n), remOp(n);
forR(i, m) {
addOp[l[i]].push_back(i);
if(r[i] + 1 < n) remOp[r[i]+1].push_back(i);
}
vi ret(n);
forR(i, n) {
for(int j : addOp[i]) ch[j] = v[j];
for(int j : remOp[i]) ch[j] = 0;
int cur = 0;
forR(j, m) cur = max(0, min(c[i], cur + ch[j]));
ret[i] = cur;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
552 KB |
Output is correct |
5 |
Correct |
6 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5039 ms |
29668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
584 ms |
11868 KB |
Output is correct |
3 |
Correct |
574 ms |
14416 KB |
Output is correct |
4 |
Execution timed out |
5061 ms |
30556 KB |
Time limit exceeded |
5 |
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 |
572 ms |
9696 KB |
Output is correct |
4 |
Correct |
575 ms |
13444 KB |
Output is correct |
5 |
Execution timed out |
5043 ms |
22088 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
552 KB |
Output is correct |
5 |
Correct |
6 ms |
716 KB |
Output is correct |
6 |
Execution timed out |
5039 ms |
29668 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |