# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
496994 |
2021-12-22T08:08:39 Z |
Nalrimet |
Meteors (POI11_met) |
C++17 |
|
4322 ms |
65544 KB |
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define left(v) v + v
#define right(v) v + v + 1
using namespace std;
typedef long long ll;
const ll N = (ll) 3e5 + 17;
const ll M = (ll) 5e3 + 69;
int n, m, q, a[N];
ll x[N], upd[N * 4];
int l[N], r[N];
int p[N], ql[N], qr[N];
vector<int> v[N], vq[N];
ll get(int v, int tl, int tr, int pos) {
if(tl == tr) return upd[v];
int tm = (tl + tr) / 2;
if(pos <= tm) return get(left(v), tl, tm, pos) + upd[v];
else return get(right(v), tm + 1, tr, pos) + upd[v];
}
void update(int v, int tl, int tr, int ql, int qr, ll val) {
if(tr < ql || qr < tl) return;
if(ql <= tl && tr <= qr){
upd[v] += val;
return;
}
int mid = (tl + tr) / 2;
update(left(v), tl, mid, ql, qr, val);
update(right(v), mid + 1, tr, ql, qr, val);
}
main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= m; i++) {
cin >> p[i];
v[p[i]].pb(i);
}
for(int i = 1; i <= n; i++)
cin >> a[i];
cin >> q;
for(int i = 1; i <= n; i++)
ql[i] = 1, qr[i] = q + 1;
for(int i = 1; i <= q; i++)
cin >> l[i] >> r[i] >> x[i];
int ok = 1;
while(ok){
ok = 0;
memset(upd, 0, sizeof(upd));
for(int i = 1; i <= n; i++)
if(ql[i] != qr[i])
vq[(ql[i] + qr[i]) / 2].pb(i);
for(int i = 1; i <= q; i++){
if(l[i] <= r[i])
update(1, 1, m, l[i], r[i], x[i]);
else update(1, 1, m, l[i], m, x[i]), update(1, 1, m, 1, r[i], x[i]);
for(int id : vq[i]){
ok = 1;
ll sum = 0;
for(int x : v[id]) {
sum += get(1, 1, m, x);
if(sum >= a[id]) break;
}
if(sum >= a[id]) qr[id] = i;
else ql[id] = i + 1;
}
vq[i].clear();
}
}
for(int i = 1; i <= n; i++) {
if(ql[i] == q + 1) cout << "NIE\n";
else cout << ql[i] << '\n';
}
}
Compilation message
met.cpp:43:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
43 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23876 KB |
Output is correct |
2 |
Correct |
24 ms |
23896 KB |
Output is correct |
3 |
Correct |
25 ms |
23888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23876 KB |
Output is correct |
2 |
Correct |
21 ms |
23876 KB |
Output is correct |
3 |
Correct |
24 ms |
23884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
26412 KB |
Output is correct |
2 |
Correct |
398 ms |
28640 KB |
Output is correct |
3 |
Correct |
398 ms |
28224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
360 ms |
27724 KB |
Output is correct |
2 |
Correct |
376 ms |
27708 KB |
Output is correct |
3 |
Correct |
411 ms |
28900 KB |
Output is correct |
4 |
Correct |
92 ms |
26180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
199 ms |
26752 KB |
Output is correct |
2 |
Correct |
284 ms |
29252 KB |
Output is correct |
3 |
Correct |
192 ms |
25284 KB |
Output is correct |
4 |
Correct |
375 ms |
28816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
329 ms |
26064 KB |
Output is correct |
2 |
Correct |
329 ms |
27712 KB |
Output is correct |
3 |
Correct |
330 ms |
26528 KB |
Output is correct |
4 |
Correct |
425 ms |
30008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3588 ms |
48972 KB |
Output is correct |
2 |
Correct |
1321 ms |
38776 KB |
Output is correct |
3 |
Correct |
817 ms |
30148 KB |
Output is correct |
4 |
Correct |
4322 ms |
65536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3587 ms |
47740 KB |
Output is correct |
2 |
Correct |
870 ms |
37332 KB |
Output is correct |
3 |
Correct |
666 ms |
30520 KB |
Output is correct |
4 |
Runtime error |
3816 ms |
65544 KB |
Execution killed with signal 9 |