#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cerr << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 2e5 + 10;
int n, q, a[maxn], c[maxn];
vector<int> distribute_candies(vector<int> C, vector<int> L, vector<int> R, vector<int> V) {
n = C.size();
for (int i = 0; i < n; i++){
c[i] = C[i];
}
q = L.size();
for (int i = 0; i < q; i++){
if (V[i] > 0){
for (int j = L[i]; j <= R[i]; j++){
a[j] = (a[j]+V[i] >= c[j]? c[j]: a[j]+V[i]);
// debug(j, a[j]);
}
}
if (V[i] < 0){
for (int j = L[i]; j <= R[i]; j++){
a[j] = (a[j]+V[i] <= 0? 0: a[j]+V[i]);
// debug(j, a[j]);
}
}
}
vector<int> ans;
for (int i = 0; i < n; i++){
ans.push_back(a[i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5047 ms |
12892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
141 ms |
8052 KB |
Output is correct |
3 |
Correct |
160 ms |
7700 KB |
Output is correct |
4 |
Execution timed out |
5051 ms |
14048 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
344 ms |
7672 KB |
Output is correct |
4 |
Correct |
342 ms |
5820 KB |
Output is correct |
5 |
Execution timed out |
5086 ms |
11620 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
428 KB |
Output is correct |
6 |
Execution timed out |
5047 ms |
12892 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |