#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
vector<int> distribute_candies (vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
vector<int> p;
p.resize(c.size());
for(int query = 0; query < v.size(); query++) {
for(int i = l[query]; i <= r[query]; i++) {
p[i] += v[query];
p[i] = max(0, p[i]);
p[i] = min(c[i], p[i]);
}
// for(int i = 0; i < p.size(); i++) cout << p[i] << " "; cout << endl;
}
return p;
}
#ifdef ngu
int main() {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
int n, q; cin >> n >> q;
vector<int> c(n), l(q), r(q), v(q);
for(int i = 0; i < n; i++) cin >> c[i];
for(int i = 0; i < q; i++) cin >> l[i] >> r[i] >> v[i];
vector<int> ans = distribute_candies(c, l, r, v);
// for(int &j : ans) cout << j << " ";
}
#endif // ngu
Compilation message
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:11:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | for(int query = 0; query < v.size(); query++) {
| ~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5089 ms |
9200 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
173 ms |
6312 KB |
Output is correct |
3 |
Correct |
180 ms |
4472 KB |
Output is correct |
4 |
Execution timed out |
5034 ms |
7896 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
434 ms |
6300 KB |
Output is correct |
4 |
Correct |
455 ms |
3440 KB |
Output is correct |
5 |
Execution timed out |
5035 ms |
8124 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Execution timed out |
5089 ms |
9200 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |