# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
443238 | 2021-07-10T08:21:34 Z | gs12117 | Meteors (POI11_met) | C++14 | 3397 ms | 65536 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; } void para_chk(int x, int parav) { long long int sum = 0; for (int i = 0; i < owned_stn[x].size(); i++) { sum += itcalc(owned_stn[x][i]); if (sum >= p[x])break; } if (p[x] <= sum)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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 22652 KB | Output is correct |
2 | Correct | 32 ms | 22604 KB | Output is correct |
3 | Correct | 36 ms | 22608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 22560 KB | Output is correct |
2 | Correct | 29 ms | 22672 KB | Output is correct |
3 | Correct | 34 ms | 22776 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 206 ms | 24132 KB | Output is correct |
2 | Correct | 276 ms | 25352 KB | Output is correct |
3 | Correct | 260 ms | 25924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 258 ms | 25260 KB | Output is correct |
2 | Correct | 260 ms | 25276 KB | Output is correct |
3 | Correct | 307 ms | 26420 KB | Output is correct |
4 | Correct | 65 ms | 24292 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 146 ms | 24736 KB | Output is correct |
2 | Correct | 167 ms | 26324 KB | Output is correct |
3 | Correct | 142 ms | 23476 KB | Output is correct |
4 | Correct | 254 ms | 26424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 269 ms | 23876 KB | Output is correct |
2 | Correct | 248 ms | 25288 KB | Output is correct |
3 | Correct | 227 ms | 24244 KB | Output is correct |
4 | Correct | 308 ms | 27276 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2228 ms | 40008 KB | Output is correct |
2 | Correct | 661 ms | 29800 KB | Output is correct |
3 | Correct | 591 ms | 29148 KB | Output is correct |
4 | Correct | 3397 ms | 65408 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2439 ms | 39124 KB | Output is correct |
2 | Correct | 681 ms | 29764 KB | Output is correct |
3 | Correct | 498 ms | 28384 KB | Output is correct |
4 | Correct | 3228 ms | 65536 KB | Output is correct |