# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
496739 |
2021-12-22T03:46:40 Z |
Nalrimet |
Meteors (POI11_met) |
C++17 |
|
3224 ms |
40428 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 * 3];
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 |
16 ms |
21452 KB |
Output is correct |
2 |
Correct |
17 ms |
21540 KB |
Output is correct |
3 |
Correct |
17 ms |
21452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
21452 KB |
Output is correct |
2 |
Correct |
15 ms |
21544 KB |
Output is correct |
3 |
Correct |
17 ms |
21580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
322 ms |
23304 KB |
Output is correct |
2 |
Correct |
381 ms |
25096 KB |
Output is correct |
3 |
Correct |
376 ms |
24796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
351 ms |
24224 KB |
Output is correct |
2 |
Correct |
365 ms |
24272 KB |
Output is correct |
3 |
Correct |
368 ms |
25348 KB |
Output is correct |
4 |
Correct |
82 ms |
23540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
23652 KB |
Output is correct |
2 |
Correct |
304 ms |
25712 KB |
Output is correct |
3 |
Correct |
161 ms |
22368 KB |
Output is correct |
4 |
Correct |
391 ms |
25232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
338 ms |
22856 KB |
Output is correct |
2 |
Correct |
318 ms |
24180 KB |
Output is correct |
3 |
Correct |
331 ms |
23092 KB |
Output is correct |
4 |
Correct |
391 ms |
26416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3224 ms |
40428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3204 ms |
38876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |