# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209781 | 2020-03-15T14:13:06 Z | Alexa2001 | Pilot (NOI19_pilot) | C++17 | 1000 ms | 107880 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) printf("%lld\n", ans[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47352 KB | Output is correct |
4 | Correct | 37 ms | 47352 KB | Output is correct |
5 | Correct | 41 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 36 ms | 47352 KB | Output is correct |
8 | Correct | 35 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 38 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47352 KB | Output is correct |
4 | Correct | 37 ms | 47352 KB | Output is correct |
5 | Correct | 41 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 36 ms | 47352 KB | Output is correct |
8 | Correct | 35 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 38 ms | 47352 KB | Output is correct |
11 | Correct | 36 ms | 47352 KB | Output is correct |
12 | Correct | 36 ms | 47352 KB | Output is correct |
13 | Correct | 36 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 35 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47352 KB | Output is correct |
4 | Correct | 37 ms | 47352 KB | Output is correct |
5 | Correct | 41 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 36 ms | 47352 KB | Output is correct |
8 | Correct | 35 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 38 ms | 47352 KB | Output is correct |
11 | Correct | 36 ms | 47352 KB | Output is correct |
12 | Correct | 36 ms | 47352 KB | Output is correct |
13 | Correct | 36 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 35 ms | 47352 KB | Output is correct |
16 | Correct | 35 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 35 ms | 47352 KB | Output is correct |
19 | Correct | 36 ms | 47352 KB | Output is correct |
20 | Correct | 36 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47352 KB | Output is correct |
4 | Correct | 37 ms | 47352 KB | Output is correct |
5 | Correct | 41 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 36 ms | 47352 KB | Output is correct |
8 | Correct | 35 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 38 ms | 47352 KB | Output is correct |
11 | Correct | 36 ms | 47352 KB | Output is correct |
12 | Correct | 36 ms | 47352 KB | Output is correct |
13 | Correct | 36 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 35 ms | 47352 KB | Output is correct |
16 | Correct | 35 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 35 ms | 47352 KB | Output is correct |
19 | Correct | 36 ms | 47352 KB | Output is correct |
20 | Correct | 36 ms | 47352 KB | Output is correct |
21 | Correct | 36 ms | 47348 KB | Output is correct |
22 | Correct | 39 ms | 47464 KB | Output is correct |
23 | Correct | 40 ms | 47352 KB | Output is correct |
24 | Correct | 42 ms | 47480 KB | Output is correct |
25 | Correct | 37 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 50296 KB | Output is correct |
2 | Correct | 76 ms | 51320 KB | Output is correct |
3 | Correct | 57 ms | 50168 KB | Output is correct |
4 | Correct | 70 ms | 51064 KB | Output is correct |
5 | Correct | 54 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 | 90 ms | 55544 KB | Output is correct |
4 | Correct | 103 ms | 55672 KB | Output is correct |
5 | Correct | 90 ms | 55416 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 94 ms | 55632 KB | Output is correct |
2 | Correct | 98 ms | 55544 KB | Output is correct |
3 | Correct | 96 ms | 55672 KB | Output is correct |
4 | Correct | 94 ms | 55800 KB | Output is correct |
5 | Correct | 101 ms | 55928 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47352 KB | Output is correct |
4 | Correct | 37 ms | 47352 KB | Output is correct |
5 | Correct | 41 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 36 ms | 47352 KB | Output is correct |
8 | Correct | 35 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 38 ms | 47352 KB | Output is correct |
11 | Correct | 55 ms | 50296 KB | Output is correct |
12 | Correct | 76 ms | 51320 KB | Output is correct |
13 | Correct | 57 ms | 50168 KB | Output is correct |
14 | Correct | 70 ms | 51064 KB | Output is correct |
15 | Correct | 54 ms | 50168 KB | Output is correct |
16 | Correct | 54 ms | 50168 KB | Output is correct |
17 | Correct | 74 ms | 51236 KB | Output is correct |
18 | Correct | 73 ms | 51320 KB | Output is correct |
19 | Correct | 54 ms | 50168 KB | Output is correct |
20 | Correct | 72 ms | 51192 KB | Output is correct |
21 | Correct | 53 ms | 50040 KB | Output is correct |
22 | Correct | 72 ms | 51064 KB | Output is correct |
23 | Correct | 57 ms | 50296 KB | Output is correct |
24 | Correct | 71 ms | 51064 KB | Output is correct |
25 | Correct | 53 ms | 50296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47352 KB | Output is correct |
4 | Correct | 37 ms | 47352 KB | Output is correct |
5 | Correct | 41 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 36 ms | 47352 KB | Output is correct |
8 | Correct | 35 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 38 ms | 47352 KB | Output is correct |
11 | Correct | 36 ms | 47352 KB | Output is correct |
12 | Correct | 36 ms | 47352 KB | Output is correct |
13 | Correct | 36 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 35 ms | 47352 KB | Output is correct |
16 | Correct | 35 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 35 ms | 47352 KB | Output is correct |
19 | Correct | 36 ms | 47352 KB | Output is correct |
20 | Correct | 36 ms | 47352 KB | Output is correct |
21 | Correct | 36 ms | 47348 KB | Output is correct |
22 | Correct | 39 ms | 47464 KB | Output is correct |
23 | Correct | 40 ms | 47352 KB | Output is correct |
24 | Correct | 42 ms | 47480 KB | Output is correct |
25 | Correct | 37 ms | 47352 KB | Output is correct |
26 | Correct | 55 ms | 50296 KB | Output is correct |
27 | Correct | 76 ms | 51320 KB | Output is correct |
28 | Correct | 57 ms | 50168 KB | Output is correct |
29 | Correct | 70 ms | 51064 KB | Output is correct |
30 | Correct | 54 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 | 90 ms | 55544 KB | Output is correct |
34 | Correct | 103 ms | 55672 KB | Output is correct |
35 | Correct | 90 ms | 55416 KB | Output is correct |
36 | Correct | 94 ms | 55632 KB | Output is correct |
37 | Correct | 98 ms | 55544 KB | Output is correct |
38 | Correct | 96 ms | 55672 KB | Output is correct |
39 | Correct | 94 ms | 55800 KB | Output is correct |
40 | Correct | 101 ms | 55928 KB | Output is correct |
41 | Correct | 54 ms | 50168 KB | Output is correct |
42 | Correct | 74 ms | 51236 KB | Output is correct |
43 | Correct | 73 ms | 51320 KB | Output is correct |
44 | Correct | 54 ms | 50168 KB | Output is correct |
45 | Correct | 72 ms | 51192 KB | Output is correct |
46 | Correct | 53 ms | 50040 KB | Output is correct |
47 | Correct | 72 ms | 51064 KB | Output is correct |
48 | Correct | 57 ms | 50296 KB | Output is correct |
49 | Correct | 71 ms | 51064 KB | Output is correct |
50 | Correct | 53 ms | 50296 KB | Output is correct |
51 | Correct | 99 ms | 54396 KB | Output is correct |
52 | Correct | 116 ms | 55288 KB | Output is correct |
53 | Correct | 105 ms | 54400 KB | Output is correct |
54 | Correct | 123 ms | 55160 KB | Output is correct |
55 | Correct | 100 ms | 54264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47352 KB | Output is correct |
4 | Correct | 37 ms | 47352 KB | Output is correct |
5 | Correct | 41 ms | 47352 KB | Output is correct |
6 | Correct | 36 ms | 47352 KB | Output is correct |
7 | Correct | 36 ms | 47352 KB | Output is correct |
8 | Correct | 35 ms | 47352 KB | Output is correct |
9 | Correct | 36 ms | 47352 KB | Output is correct |
10 | Correct | 38 ms | 47352 KB | Output is correct |
11 | Correct | 36 ms | 47352 KB | Output is correct |
12 | Correct | 36 ms | 47352 KB | Output is correct |
13 | Correct | 36 ms | 47352 KB | Output is correct |
14 | Correct | 38 ms | 47352 KB | Output is correct |
15 | Correct | 35 ms | 47352 KB | Output is correct |
16 | Correct | 35 ms | 47352 KB | Output is correct |
17 | Correct | 37 ms | 47352 KB | Output is correct |
18 | Correct | 35 ms | 47352 KB | Output is correct |
19 | Correct | 36 ms | 47352 KB | Output is correct |
20 | Correct | 36 ms | 47352 KB | Output is correct |
21 | Correct | 36 ms | 47348 KB | Output is correct |
22 | Correct | 39 ms | 47464 KB | Output is correct |
23 | Correct | 40 ms | 47352 KB | Output is correct |
24 | Correct | 42 ms | 47480 KB | Output is correct |
25 | Correct | 37 ms | 47352 KB | Output is correct |
26 | Correct | 55 ms | 50296 KB | Output is correct |
27 | Correct | 76 ms | 51320 KB | Output is correct |
28 | Correct | 57 ms | 50168 KB | Output is correct |
29 | Correct | 70 ms | 51064 KB | Output is correct |
30 | Correct | 54 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 | 90 ms | 55544 KB | Output is correct |
34 | Correct | 103 ms | 55672 KB | Output is correct |
35 | Correct | 90 ms | 55416 KB | Output is correct |
36 | Correct | 94 ms | 55632 KB | Output is correct |
37 | Correct | 98 ms | 55544 KB | Output is correct |
38 | Correct | 96 ms | 55672 KB | Output is correct |
39 | Correct | 94 ms | 55800 KB | Output is correct |
40 | Correct | 101 ms | 55928 KB | Output is correct |
41 | Correct | 54 ms | 50168 KB | Output is correct |
42 | Correct | 74 ms | 51236 KB | Output is correct |
43 | Correct | 73 ms | 51320 KB | Output is correct |
44 | Correct | 54 ms | 50168 KB | Output is correct |
45 | Correct | 72 ms | 51192 KB | Output is correct |
46 | Correct | 53 ms | 50040 KB | Output is correct |
47 | Correct | 72 ms | 51064 KB | Output is correct |
48 | Correct | 57 ms | 50296 KB | Output is correct |
49 | Correct | 71 ms | 51064 KB | Output is correct |
50 | Correct | 53 ms | 50296 KB | Output is correct |
51 | Correct | 99 ms | 54396 KB | Output is correct |
52 | Correct | 116 ms | 55288 KB | Output is correct |
53 | Correct | 105 ms | 54400 KB | Output is correct |
54 | Correct | 123 ms | 55160 KB | Output is correct |
55 | Correct | 100 ms | 54264 KB | Output is correct |
56 | Execution timed out | 1028 ms | 107880 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |