#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll inf = 1e9;
const int md1 = 1e9+7;
const int md2 = 998244353;
#define sz(v) ((int)v.size())
#define pb push_back
#define pry cout << "YES\n"
#define prn cout << "NO\n"
#define endl '\n'
#define fst first
#define scn second
/* #define ONPC */
using vi = vector<int>;
vi
sub1(vi &c, vi &l, vi &r, vi &v)
{
int n = sz(c);
int q = sz(l);
vi ans;
ll val;
for (int i = 0; i < n; ++i) {
val = 0;
for (int j = 0; j < q; ++j) {
if (i < l[j] || i > r[j])
continue;
val += (ll)v[j];
val = min(val,(ll)c[i]);
val = max(val,0ll);
}
ans.pb(val);
}
return ans;
}
vi
distribute_candies(vi c, vi l, vi r, vi v)
{
int n = sz(c);
int q = sz(l);
if (n < 3e5 && q < 3e5)
return sub1(c,l,r,v);
vi tans;
for (int i = 0; i < n; ++i)
tans.pb(69);
return tans;
}
#ifdef ONPC
void
solve()
{
int n, q;
cin >> n >> q;
vector<int> c(n);
for (int i = 0; i < n; ++i)
cin >> c[i];
vector<int> l(q), r(q), v(q);
for (int i = 0; i < q; ++i)
cin >> l[i] >> r[i] >> v[i];
vi ans = distribute_candies(c,l,r,v);
for (int i = 0; i < sz(ans); ++i) {
cout << ans[i] << ' ';
}
cout << endl;
}
int32_t
main(int argc, char **argv)
{
if (argc >= 2) {
freopen(argv[1], "r", stdin);
} else
ios_base::sync_with_stdio(0);cin.tie(0);
int t = 1;
/* cin >> t; */
while(t--)
solve();
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
340 KB |
Output is correct |
5 |
Correct |
11 ms |
372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5031 ms |
7764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1763 ms |
8040 KB |
Output is correct |
3 |
Correct |
799 ms |
4032 KB |
Output is correct |
4 |
Execution timed out |
5029 ms |
12916 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
926 ms |
7656 KB |
Output is correct |
4 |
Correct |
875 ms |
4368 KB |
Output is correct |
5 |
Execution timed out |
5058 ms |
10144 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 |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
11 ms |
372 KB |
Output is correct |
6 |
Execution timed out |
5031 ms |
7764 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |