# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443236 | 2021-07-10T08:15:53 Z | gs12117 | Meteors (POI11_met) | C++14 | 2166 ms | 40776 KB |
#include<cstdio> #include<vector> int n, m, q; int o[300100]; std::vector<int> owned_stn[300100]; long long int p[300100]; int l[300100]; int r[300100]; long long int a[300100]; int ans[300100]; std::vector<int> check_for_q[300100]; const long long int itsz = 1 << 19; long long int it[2 * itsz]; void itpush(int s, int e, long long int v) { s += itsz; e += itsz; while (s <= e) { if (s % 2 == 1) { it[s] += v; s++; } if (e % 2 == 0) { it[e] += v; e--; } s /= 2; e /= 2; } } long long int itcalc(int x) { x += itsz; long long int res = 0; while (x > 0) { res += it[x]; x /= 2; } return res; } long long int calcx(int x) { long long int sum = 0; for (int i = 0; i < owned_stn[x].size(); i++) { sum += itcalc(owned_stn[x][i]); } return sum; } void para_chk(int x, int parav) { if (p[x] <= calcx(x))ans[x] -= parav; } void para(int parav) { for (int i = 0; i <= q + 3; i++) { check_for_q[i].clear(); } for (int i = 1; i <= n; i++) { ans[i] += parav; if (ans[i] > q)ans[i] -= parav; else check_for_q[ans[i]].push_back(i); } for (int i = 0; i < 2 * itsz; i++) { it[i] = 0; } for (int i = 1; i <= q; i++) { if (l[i] <= r[i]) { itpush(l[i], r[i], a[i]); } else { itpush(l[i], m, a[i]); itpush(1, r[i], a[i]); } for (int j = 0; j < check_for_q[i].size(); j++) { int x = check_for_q[i][j]; para_chk(x, parav); } } } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d", &o[i]); owned_stn[o[i]].push_back(i); } for (int i = 1; i <= n; i++) { scanf("%lld", &p[i]); } scanf("%d", &q); for (int i = 1; i <= q; i++) { scanf("%d%d%lld", &l[i], &r[i], &a[i]); } for (int i = 18; i >= 0; i--) { para(1 << i); } for (int i = 1; i <= n; i++) { if (ans[i] >= q) { printf("NIE\n"); } else { printf("%d\n", ans[i] + 1); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 22676 KB | Output is correct |
2 | Correct | 27 ms | 22680 KB | Output is correct |
3 | Correct | 25 ms | 22604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 22604 KB | Output is correct |
2 | Correct | 28 ms | 22672 KB | Output is correct |
3 | Correct | 26 ms | 22704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 217 ms | 24988 KB | Output is correct |
2 | Correct | 276 ms | 26244 KB | Output is correct |
3 | Correct | 260 ms | 26692 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 271 ms | 26080 KB | Output is correct |
2 | Correct | 260 ms | 26224 KB | Output is correct |
3 | Correct | 315 ms | 27144 KB | Output is correct |
4 | Correct | 64 ms | 24764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 142 ms | 25520 KB | Output is correct |
2 | Correct | 161 ms | 27044 KB | Output is correct |
3 | Correct | 145 ms | 24112 KB | Output is correct |
4 | Correct | 263 ms | 27156 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 271 ms | 24696 KB | Output is correct |
2 | Correct | 271 ms | 26164 KB | Output is correct |
3 | Correct | 222 ms | 24900 KB | Output is correct |
4 | Correct | 302 ms | 27992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2098 ms | 40776 KB | Output is correct |
2 | Incorrect | 722 ms | 30492 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2166 ms | 39884 KB | Output is correct |
2 | Incorrect | 692 ms | 30524 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |