# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347627 | 2021-01-13T09:35:06 Z | IvanJ | Meteors (POI11_met) | C++17 | 1068 ms | 65540 KB |
#include<bits/stdc++.h> #define pb push_back #define x first #define y second using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 3e5 + 5; int n, m, k; vector<int> own[maxn]; ll need[maxn]; pair<ii, int> qs[maxn]; vector<pair<ii, int>> A[maxn]; vector<pair<ii, int>> A1[maxn]; int ans[maxn], ok[maxn]; ll fwt[maxn]; void update(int x, int v) { x++; for(;x < maxn;x += (x & -x)) fwt[x] += (ll)v; } ll query(int x) { x++; ll ret = 0; for(;x > 0;x -= (x & -x)) ret += fwt[x]; return ret; } int main() { scanf("%d %d", &n, &m); for(int i = 0;i < m;i++) { int x;scanf("%d", &x);x--; own[x].pb(i); } for(int i = 0;i < n;i++) scanf("%lld", need + i); scanf("%d", &k); for(int i = 0;i < k;i++) { int l, r, a; scanf("%d %d %d", &l, &r, &a); l--, r--; qs[i] = {{l, r}, a}; } for(int i = 0;i < n;i++) { int mid = k - 1; A[mid].pb({{0, k - 1}, i}); } while(true) { for(int i = 0;i < maxn;i++) fwt[i] = 0; int flag = 0; for(int i = 0;i < k;i++) { if(qs[i].x.x > qs[i].x.y) { update(qs[i].x.x, qs[i].y); update(0, qs[i].y); update(qs[i].x.y + 1, -qs[i].y); } else { update(qs[i].x.x, qs[i].y); update(qs[i].x.y + 1, -qs[i].y); } for(pair<ii, int> p : A[i]) { //cout << i << "->" << p.x.x << ' ' << p.x.y << " (" << p.y << ")\n"; if(p.x.x > p.x.y) {A1[i].pb(p);continue;} flag = 1; ll sum = 0; for(int j : own[p.y]) sum += query(j); pair<ii, int> p1 = p; if(sum <= need[p.y]) p1.x.x = i + 1, A1[(i + 1 + p.x.y) / 2].pb(p1); if(sum >= need[p.y]) ok[p.y] = 1; if(sum > need[p.y]) p1.x.y = i - 1, A1[(p.x.x + i - 1) / 2].pb(p1); } } for(int i = 0;i < k;i++) A[i] = A1[i], A1[i].clear(); if(!flag) break; } for(int i = 0;i < k;i++) { for(pair<ii, int> p : A[i]) if(ok[p.y]) ans[p.y] = i + 1; } for(int i = 0;i < n;i++) { if(!ans[i]) printf("NIE\n"); else printf("%d\n", ans[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 22 ms | 23916 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 22 ms | 23916 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 115 ms | 25068 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 173 ms | 29564 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 149 ms | 27116 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 161 ms | 25068 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 981 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1068 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |