# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209778 | 2020-03-15T14:11:27 Z | Alexa2001 | Pilot (NOI19_pilot) | C++17 | 1000 ms | 107896 KB |
#include <bits/stdc++.h> using namespace std; /// 16:02 typedef long long ll; const int Nmax = 1e6 + 5; ll act = 0; vector<int> v[Nmax], w[Nmax]; int n, q; ll ans[Nmax]; int t[Nmax], sz[Nmax]; ll take2(int x) { return (ll)x*(x+1)/2; } int boss(int x) { if(x == t[x]) return x; return t[x] = boss(t[x]); } void unite(int x, int y) { x = boss(x); y = boss(y); act -= take2(sz[y]) + take2(sz[x]); if(sz[x] > sz[y]) swap(x, y); t[x] = y; sz[y] += sz[x]; act += take2(sz[y]); } void add(int x) { sz[x] = 1; t[x] = x; ++act; if(sz[x-1]) unite(x, x-1); if(sz[x+1]) unite(x, x+1); } const int bsize = 1 << 18; char buffer[bsize+2]; int cursor; static inline void init_read() { fread(buffer, 1, bsize, stdin), cursor = 0; } template<typename T> void read(T &x) { x = 0; while(!isdigit(buffer[cursor])) { ++cursor; if(cursor == bsize) init_read(); } while(isdigit(buffer[cursor])) { x = x * 10 + buffer[cursor] - '0'; ++cursor; if(cursor == bsize) init_read(); } } int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); cin.tie(0); init_read(); read(n); read(q); int i; for(i=1; i<=n; ++i) { int x; read(x); w[x].push_back(i); } for(i=1; i<=q; ++i) { int x; read(x); v[x].push_back(i); } for(i=1; i<=Nmax-5; ++i) { for(auto it : w[i]) add(it); for(auto it : v[i]) ans[it] = act; } for(i=1; i<=q; ++i) cout << ans[i] << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 37 ms | 47352 KB | Output is correct |
3 | Correct | 38 ms | 47352 KB | Output is correct |
4 | Correct | 36 ms | 47352 KB | Output is correct |
5 | Correct | 37 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 37 ms | 47352 KB | Output is correct |
8 | Correct | 37 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 37 ms | 47332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 37 ms | 47352 KB | Output is correct |
3 | Correct | 38 ms | 47352 KB | Output is correct |
4 | Correct | 36 ms | 47352 KB | Output is correct |
5 | Correct | 37 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 37 ms | 47352 KB | Output is correct |
8 | Correct | 37 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 37 ms | 47332 KB | Output is correct |
11 | Correct | 35 ms | 47352 KB | Output is correct |
12 | Correct | 37 ms | 47356 KB | Output is correct |
13 | Correct | 37 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 37 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 37 ms | 47352 KB | Output is correct |
3 | Correct | 38 ms | 47352 KB | Output is correct |
4 | Correct | 36 ms | 47352 KB | Output is correct |
5 | Correct | 37 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 37 ms | 47352 KB | Output is correct |
8 | Correct | 37 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 37 ms | 47332 KB | Output is correct |
11 | Correct | 35 ms | 47352 KB | Output is correct |
12 | Correct | 37 ms | 47356 KB | Output is correct |
13 | Correct | 37 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 37 ms | 47352 KB | Output is correct |
16 | Correct | 41 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 37 ms | 47352 KB | Output is correct |
19 | Correct | 40 ms | 47352 KB | Output is correct |
20 | Correct | 37 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 37 ms | 47352 KB | Output is correct |
3 | Correct | 38 ms | 47352 KB | Output is correct |
4 | Correct | 36 ms | 47352 KB | Output is correct |
5 | Correct | 37 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 37 ms | 47352 KB | Output is correct |
8 | Correct | 37 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 37 ms | 47332 KB | Output is correct |
11 | Correct | 35 ms | 47352 KB | Output is correct |
12 | Correct | 37 ms | 47356 KB | Output is correct |
13 | Correct | 37 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 37 ms | 47352 KB | Output is correct |
16 | Correct | 41 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 37 ms | 47352 KB | Output is correct |
19 | Correct | 40 ms | 47352 KB | Output is correct |
20 | Correct | 37 ms | 47352 KB | Output is correct |
21 | Correct | 44 ms | 47480 KB | Output is correct |
22 | Correct | 38 ms | 47460 KB | Output is correct |
23 | Correct | 37 ms | 47352 KB | Output is correct |
24 | Correct | 37 ms | 47352 KB | Output is correct |
25 | Correct | 38 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 50312 KB | Output is correct |
2 | Correct | 74 ms | 51320 KB | Output is correct |
3 | Correct | 55 ms | 50168 KB | Output is correct |
4 | Correct | 72 ms | 50936 KB | Output is correct |
5 | Correct | 57 ms | 50168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 55416 KB | Output is correct |
2 | Correct | 88 ms | 55544 KB | Output is correct |
3 | Correct | 86 ms | 55452 KB | Output is correct |
4 | Correct | 84 ms | 55672 KB | Output is correct |
5 | Correct | 83 ms | 55416 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 93 ms | 55544 KB | Output is correct |
2 | Correct | 94 ms | 55544 KB | Output is correct |
3 | Correct | 96 ms | 55672 KB | Output is correct |
4 | Correct | 100 ms | 55776 KB | Output is correct |
5 | Correct | 93 ms | 55864 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 37 ms | 47352 KB | Output is correct |
3 | Correct | 38 ms | 47352 KB | Output is correct |
4 | Correct | 36 ms | 47352 KB | Output is correct |
5 | Correct | 37 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 37 ms | 47352 KB | Output is correct |
8 | Correct | 37 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 37 ms | 47332 KB | Output is correct |
11 | Correct | 55 ms | 50312 KB | Output is correct |
12 | Correct | 74 ms | 51320 KB | Output is correct |
13 | Correct | 55 ms | 50168 KB | Output is correct |
14 | Correct | 72 ms | 50936 KB | Output is correct |
15 | Correct | 57 ms | 50168 KB | Output is correct |
16 | Correct | 54 ms | 50168 KB | Output is correct |
17 | Correct | 77 ms | 51320 KB | Output is correct |
18 | Correct | 80 ms | 51320 KB | Output is correct |
19 | Correct | 58 ms | 50168 KB | Output is correct |
20 | Correct | 75 ms | 51192 KB | Output is correct |
21 | Correct | 53 ms | 50040 KB | Output is correct |
22 | Correct | 69 ms | 51068 KB | Output is correct |
23 | Correct | 57 ms | 50296 KB | Output is correct |
24 | Correct | 71 ms | 51064 KB | Output is correct |
25 | Correct | 54 ms | 50296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 37 ms | 47352 KB | Output is correct |
3 | Correct | 38 ms | 47352 KB | Output is correct |
4 | Correct | 36 ms | 47352 KB | Output is correct |
5 | Correct | 37 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 37 ms | 47352 KB | Output is correct |
8 | Correct | 37 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 37 ms | 47332 KB | Output is correct |
11 | Correct | 35 ms | 47352 KB | Output is correct |
12 | Correct | 37 ms | 47356 KB | Output is correct |
13 | Correct | 37 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 37 ms | 47352 KB | Output is correct |
16 | Correct | 41 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 37 ms | 47352 KB | Output is correct |
19 | Correct | 40 ms | 47352 KB | Output is correct |
20 | Correct | 37 ms | 47352 KB | Output is correct |
21 | Correct | 44 ms | 47480 KB | Output is correct |
22 | Correct | 38 ms | 47460 KB | Output is correct |
23 | Correct | 37 ms | 47352 KB | Output is correct |
24 | Correct | 37 ms | 47352 KB | Output is correct |
25 | Correct | 38 ms | 47352 KB | Output is correct |
26 | Correct | 55 ms | 50312 KB | Output is correct |
27 | Correct | 74 ms | 51320 KB | Output is correct |
28 | Correct | 55 ms | 50168 KB | Output is correct |
29 | Correct | 72 ms | 50936 KB | Output is correct |
30 | Correct | 57 ms | 50168 KB | Output is correct |
31 | Correct | 86 ms | 55416 KB | Output is correct |
32 | Correct | 88 ms | 55544 KB | Output is correct |
33 | Correct | 86 ms | 55452 KB | Output is correct |
34 | Correct | 84 ms | 55672 KB | Output is correct |
35 | Correct | 83 ms | 55416 KB | Output is correct |
36 | Correct | 93 ms | 55544 KB | Output is correct |
37 | Correct | 94 ms | 55544 KB | Output is correct |
38 | Correct | 96 ms | 55672 KB | Output is correct |
39 | Correct | 100 ms | 55776 KB | Output is correct |
40 | Correct | 93 ms | 55864 KB | Output is correct |
41 | Correct | 54 ms | 50168 KB | Output is correct |
42 | Correct | 77 ms | 51320 KB | Output is correct |
43 | Correct | 80 ms | 51320 KB | Output is correct |
44 | Correct | 58 ms | 50168 KB | Output is correct |
45 | Correct | 75 ms | 51192 KB | Output is correct |
46 | Correct | 53 ms | 50040 KB | Output is correct |
47 | Correct | 69 ms | 51068 KB | Output is correct |
48 | Correct | 57 ms | 50296 KB | Output is correct |
49 | Correct | 71 ms | 51064 KB | Output is correct |
50 | Correct | 54 ms | 50296 KB | Output is correct |
51 | Correct | 111 ms | 54392 KB | Output is correct |
52 | Correct | 129 ms | 55268 KB | Output is correct |
53 | Correct | 109 ms | 54264 KB | Output is correct |
54 | Correct | 125 ms | 55264 KB | Output is correct |
55 | Correct | 100 ms | 54264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 37 ms | 47352 KB | Output is correct |
3 | Correct | 38 ms | 47352 KB | Output is correct |
4 | Correct | 36 ms | 47352 KB | Output is correct |
5 | Correct | 37 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 37 ms | 47352 KB | Output is correct |
8 | Correct | 37 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 37 ms | 47332 KB | Output is correct |
11 | Correct | 35 ms | 47352 KB | Output is correct |
12 | Correct | 37 ms | 47356 KB | Output is correct |
13 | Correct | 37 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 37 ms | 47352 KB | Output is correct |
16 | Correct | 41 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 37 ms | 47352 KB | Output is correct |
19 | Correct | 40 ms | 47352 KB | Output is correct |
20 | Correct | 37 ms | 47352 KB | Output is correct |
21 | Correct | 44 ms | 47480 KB | Output is correct |
22 | Correct | 38 ms | 47460 KB | Output is correct |
23 | Correct | 37 ms | 47352 KB | Output is correct |
24 | Correct | 37 ms | 47352 KB | Output is correct |
25 | Correct | 38 ms | 47352 KB | Output is correct |
26 | Correct | 55 ms | 50312 KB | Output is correct |
27 | Correct | 74 ms | 51320 KB | Output is correct |
28 | Correct | 55 ms | 50168 KB | Output is correct |
29 | Correct | 72 ms | 50936 KB | Output is correct |
30 | Correct | 57 ms | 50168 KB | Output is correct |
31 | Correct | 86 ms | 55416 KB | Output is correct |
32 | Correct | 88 ms | 55544 KB | Output is correct |
33 | Correct | 86 ms | 55452 KB | Output is correct |
34 | Correct | 84 ms | 55672 KB | Output is correct |
35 | Correct | 83 ms | 55416 KB | Output is correct |
36 | Correct | 93 ms | 55544 KB | Output is correct |
37 | Correct | 94 ms | 55544 KB | Output is correct |
38 | Correct | 96 ms | 55672 KB | Output is correct |
39 | Correct | 100 ms | 55776 KB | Output is correct |
40 | Correct | 93 ms | 55864 KB | Output is correct |
41 | Correct | 54 ms | 50168 KB | Output is correct |
42 | Correct | 77 ms | 51320 KB | Output is correct |
43 | Correct | 80 ms | 51320 KB | Output is correct |
44 | Correct | 58 ms | 50168 KB | Output is correct |
45 | Correct | 75 ms | 51192 KB | Output is correct |
46 | Correct | 53 ms | 50040 KB | Output is correct |
47 | Correct | 69 ms | 51068 KB | Output is correct |
48 | Correct | 57 ms | 50296 KB | Output is correct |
49 | Correct | 71 ms | 51064 KB | Output is correct |
50 | Correct | 54 ms | 50296 KB | Output is correct |
51 | Correct | 111 ms | 54392 KB | Output is correct |
52 | Correct | 129 ms | 55268 KB | Output is correct |
53 | Correct | 109 ms | 54264 KB | Output is correct |
54 | Correct | 125 ms | 55264 KB | Output is correct |
55 | Correct | 100 ms | 54264 KB | Output is correct |
56 | Execution timed out | 1020 ms | 107896 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |