Submission #61566376
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;#define int long longint n, a[500005], s[500005], ft[2000005];void update(int x, int v) {while (x <= n){ft[x] += v;x += x & -x;}}int query(int x){int res = 0;while (x){res += ft[x];x -= x & -x;}return res;}
#include <bits/stdc++.h> using namespace std; #define int long long int n, a[500005], s[500005], ft[2000005]; void update(int x, int v) { while (x <= n){ ft[x] += v; x += x & -x; } } int query(int x){ int res = 0; while (x){ res += ft[x]; x -= x & -x; } return res; } int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; s[1] = a[1]; int r1 = s[1] + 1; update(r1, 1); int cnt = 1; for (int i = 2; i <= n; i++) { int z = cnt - query(i - 1); s[i] = a[i] + z; int ri = s[i] + i; update(ri, 1); cnt++; } for (int i = 1; i <= n; i++) { int lost = n - i, bi = s[i] - lost; if (bi < 0) bi = 0; cout << bi << ' '; } }
Submission Info
Submission Time | |
---|---|
Task | D - Coming of Age Celebration |
User | ThePwo |
Language | C++ 20 (gcc 12.2) |
Score | 400 |
Code Size | 896 Byte |
Status | AC |
Exec Time | 51 ms |
Memory | 15328 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt |
All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 1 ms | 3536 KB |
sample01.txt | AC | 1 ms | 3460 KB |
sample02.txt | AC | 1 ms | 3420 KB |
testcase00.txt | AC | 1 ms | 3424 KB |
testcase01.txt | AC | 40 ms | 15328 KB |
testcase02.txt | AC | 44 ms | 11696 KB |
testcase03.txt | AC | 42 ms | 13176 KB |
testcase04.txt | AC | 50 ms | 15240 KB |
testcase05.txt | AC | 13 ms | 6532 KB |
testcase06.txt | AC | 50 ms | 15112 KB |
testcase07.txt | AC | 40 ms | 12792 KB |
testcase08.txt | AC | 51 ms | 15172 KB |
testcase09.txt | AC | 42 ms | 13280 KB |
testcase10.txt | AC | 51 ms | 15132 KB |
testcase11.txt | AC | 20 ms | 8244 KB |
testcase12.txt | AC | 50 ms | 15112 KB |
testcase13.txt | AC | 31 ms | 10832 KB |
testcase14.txt | AC | 50 ms | 15140 KB |
testcase15.txt | AC | 7 ms | 4884 KB |
testcase16.txt | AC | 50 ms | 15200 KB |
testcase17.txt | AC | 42 ms | 13188 KB |
testcase18.txt | AC | 39 ms | 14468 KB |
testcase19.txt | AC | 37 ms | 14520 KB |