#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
vector<long long> distribute_candies (vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
vector<long long> 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(0LL, p[i]);
p[i] = min(1LL * 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.ans", "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<long long 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 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5016 ms |
8016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |