#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l,
vector<int> r, vector<int> v) {
int n = c.size();
vector<int> s(n);
for( int i = 0; i < n; i++ ){ s[i] = 0; }
int q = v.size();
for( int i = 0; i < q; i++ ){
//per query
for( int j = l[i]; j <= r[i]; j++ ){
if( v[i] > 0 ){ s[j] = min( c[j], s[j]+v[i] ); }
else if ( v[i] < 0 ){ s[j] = max( 0, s[j]+v[i] ); }
}
//for( int k = 0; k < n; k++ ){ cout << s[k] << " "; } cout << endl;
}
return s;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
4 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5079 ms |
11300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
230 ms |
8024 KB |
Output is correct |
3 |
Correct |
223 ms |
6016 KB |
Output is correct |
4 |
Execution timed out |
5091 ms |
12220 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
543 ms |
7640 KB |
Output is correct |
4 |
Correct |
536 ms |
3996 KB |
Output is correct |
5 |
Execution timed out |
5093 ms |
10820 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
4 ms |
332 KB |
Output is correct |
6 |
Execution timed out |
5079 ms |
11300 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |