# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
239817 | 2020-06-17T10:43:14 Z | mhy908 | Pilot (NOI19_pilot) | C++14 | 1000 ms | 70524 KB |
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define eb emplace_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define svec(x) sort(x.begin(), x.end()) #define press(x) x.erase(unique(x.begin(), x.end()), x.end()) #define lb(x, v) lower_bound(x.begin(), x.end(), v) #define ub(x, v) upper_bound(x.begin(), x.end(), v) using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; typedef pair<int, LL> pil; typedef pair<LL, int> pli; const LL llinf=2000000000000000000; const LL mod1=1000000007; const LL mod2=998244353; const int inf=2000000000; int n, q; vector<int> vc[1000010]; LL ans[1000010], nans, tmp; bool ch[1000010]; int par[1000010]; LL sz[1000010]; int findpar(int num){return num==par[num]?num:par[num]=findpar(par[num]);} void mergepar(int a, int b){ a=findpar(a); b=findpar(b); if(a==b)return; nans-=sz[a]*(sz[a]+1)/2; nans-=sz[b]*(sz[b]+1)/2; sz[a]+=sz[b]; par[b]=a; nans+=sz[a]*(sz[a]+1)/2; } int main(){ scanf("%d %d", &n, &q); for(int i=1; i<=1000000; i++)par[i]=i, sz[i]=1; nans=(LL)n; tmp=(LL)n; for(int i=1; i<=n; i++){ int a; scanf("%d", &a); vc[a].eb(i); } for(int i=1; i<=1000000; i++){ for(auto j:vc[i]){ ch[j]=true; if(ch[j+1])mergepar(j, j+1); if(ch[j-1])mergepar(j-1, j); tmp--; } ans[i]=nans-tmp; } for(int i=1; i<=q; i++){ int a; scanf("%d", &a); printf("%lld\n", ans[a]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 43392 KB | Output is correct |
2 | Correct | 36 ms | 43392 KB | Output is correct |
3 | Correct | 30 ms | 43392 KB | Output is correct |
4 | Correct | 31 ms | 43392 KB | Output is correct |
5 | Correct | 31 ms | 43384 KB | Output is correct |
6 | Correct | 31 ms | 43392 KB | Output is correct |
7 | Correct | 31 ms | 43392 KB | Output is correct |
8 | Correct | 31 ms | 43392 KB | Output is correct |
9 | Correct | 31 ms | 43392 KB | Output is correct |
10 | Correct | 31 ms | 43392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 43392 KB | Output is correct |
2 | Correct | 36 ms | 43392 KB | Output is correct |
3 | Correct | 30 ms | 43392 KB | Output is correct |
4 | Correct | 31 ms | 43392 KB | Output is correct |
5 | Correct | 31 ms | 43384 KB | Output is correct |
6 | Correct | 31 ms | 43392 KB | Output is correct |
7 | Correct | 31 ms | 43392 KB | Output is correct |
8 | Correct | 31 ms | 43392 KB | Output is correct |
9 | Correct | 31 ms | 43392 KB | Output is correct |
10 | Correct | 31 ms | 43392 KB | Output is correct |
11 | Correct | 31 ms | 43416 KB | Output is correct |
12 | Correct | 31 ms | 43392 KB | Output is correct |
13 | Correct | 37 ms | 43384 KB | Output is correct |
14 | Correct | 37 ms | 43512 KB | Output is correct |
15 | Correct | 31 ms | 43392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 43392 KB | Output is correct |
2 | Correct | 36 ms | 43392 KB | Output is correct |
3 | Correct | 30 ms | 43392 KB | Output is correct |
4 | Correct | 31 ms | 43392 KB | Output is correct |
5 | Correct | 31 ms | 43384 KB | Output is correct |
6 | Correct | 31 ms | 43392 KB | Output is correct |
7 | Correct | 31 ms | 43392 KB | Output is correct |
8 | Correct | 31 ms | 43392 KB | Output is correct |
9 | Correct | 31 ms | 43392 KB | Output is correct |
10 | Correct | 31 ms | 43392 KB | Output is correct |
11 | Correct | 31 ms | 43416 KB | Output is correct |
12 | Correct | 31 ms | 43392 KB | Output is correct |
13 | Correct | 37 ms | 43384 KB | Output is correct |
14 | Correct | 37 ms | 43512 KB | Output is correct |
15 | Correct | 31 ms | 43392 KB | Output is correct |
16 | Correct | 31 ms | 43392 KB | Output is correct |
17 | Correct | 33 ms | 43392 KB | Output is correct |
18 | Correct | 32 ms | 43384 KB | Output is correct |
19 | Correct | 31 ms | 43384 KB | Output is correct |
20 | Correct | 32 ms | 43392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 43392 KB | Output is correct |
2 | Correct | 36 ms | 43392 KB | Output is correct |
3 | Correct | 30 ms | 43392 KB | Output is correct |
4 | Correct | 31 ms | 43392 KB | Output is correct |
5 | Correct | 31 ms | 43384 KB | Output is correct |
6 | Correct | 31 ms | 43392 KB | Output is correct |
7 | Correct | 31 ms | 43392 KB | Output is correct |
8 | Correct | 31 ms | 43392 KB | Output is correct |
9 | Correct | 31 ms | 43392 KB | Output is correct |
10 | Correct | 31 ms | 43392 KB | Output is correct |
11 | Correct | 31 ms | 43416 KB | Output is correct |
12 | Correct | 31 ms | 43392 KB | Output is correct |
13 | Correct | 37 ms | 43384 KB | Output is correct |
14 | Correct | 37 ms | 43512 KB | Output is correct |
15 | Correct | 31 ms | 43392 KB | Output is correct |
16 | Correct | 31 ms | 43392 KB | Output is correct |
17 | Correct | 33 ms | 43392 KB | Output is correct |
18 | Correct | 32 ms | 43384 KB | Output is correct |
19 | Correct | 31 ms | 43384 KB | Output is correct |
20 | Correct | 32 ms | 43392 KB | Output is correct |
21 | Correct | 34 ms | 43392 KB | Output is correct |
22 | Correct | 31 ms | 43392 KB | Output is correct |
23 | Correct | 32 ms | 43384 KB | Output is correct |
24 | Correct | 33 ms | 43392 KB | Output is correct |
25 | Correct | 32 ms | 43392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 62 ms | 45416 KB | Output is correct |
2 | Correct | 83 ms | 46344 KB | Output is correct |
3 | Correct | 60 ms | 45364 KB | Output is correct |
4 | Correct | 88 ms | 46200 KB | Output is correct |
5 | Correct | 70 ms | 45336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 97 ms | 47352 KB | Output is correct |
2 | Correct | 84 ms | 47352 KB | Output is correct |
3 | Correct | 92 ms | 47352 KB | Output is correct |
4 | Correct | 91 ms | 47736 KB | Output is correct |
5 | Correct | 82 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 92 ms | 47480 KB | Output is correct |
2 | Correct | 90 ms | 47352 KB | Output is correct |
3 | Correct | 92 ms | 47352 KB | Output is correct |
4 | Correct | 88 ms | 47480 KB | Output is correct |
5 | Correct | 109 ms | 47736 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 43392 KB | Output is correct |
2 | Correct | 36 ms | 43392 KB | Output is correct |
3 | Correct | 30 ms | 43392 KB | Output is correct |
4 | Correct | 31 ms | 43392 KB | Output is correct |
5 | Correct | 31 ms | 43384 KB | Output is correct |
6 | Correct | 31 ms | 43392 KB | Output is correct |
7 | Correct | 31 ms | 43392 KB | Output is correct |
8 | Correct | 31 ms | 43392 KB | Output is correct |
9 | Correct | 31 ms | 43392 KB | Output is correct |
10 | Correct | 31 ms | 43392 KB | Output is correct |
11 | Correct | 62 ms | 45416 KB | Output is correct |
12 | Correct | 83 ms | 46344 KB | Output is correct |
13 | Correct | 60 ms | 45364 KB | Output is correct |
14 | Correct | 88 ms | 46200 KB | Output is correct |
15 | Correct | 70 ms | 45336 KB | Output is correct |
16 | Correct | 73 ms | 45304 KB | Output is correct |
17 | Correct | 85 ms | 46456 KB | Output is correct |
18 | Correct | 80 ms | 46456 KB | Output is correct |
19 | Correct | 60 ms | 45304 KB | Output is correct |
20 | Correct | 79 ms | 46328 KB | Output is correct |
21 | Correct | 60 ms | 45304 KB | Output is correct |
22 | Correct | 92 ms | 46204 KB | Output is correct |
23 | Correct | 79 ms | 45432 KB | Output is correct |
24 | Correct | 76 ms | 46200 KB | Output is correct |
25 | Correct | 62 ms | 45432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 43392 KB | Output is correct |
2 | Correct | 36 ms | 43392 KB | Output is correct |
3 | Correct | 30 ms | 43392 KB | Output is correct |
4 | Correct | 31 ms | 43392 KB | Output is correct |
5 | Correct | 31 ms | 43384 KB | Output is correct |
6 | Correct | 31 ms | 43392 KB | Output is correct |
7 | Correct | 31 ms | 43392 KB | Output is correct |
8 | Correct | 31 ms | 43392 KB | Output is correct |
9 | Correct | 31 ms | 43392 KB | Output is correct |
10 | Correct | 31 ms | 43392 KB | Output is correct |
11 | Correct | 31 ms | 43416 KB | Output is correct |
12 | Correct | 31 ms | 43392 KB | Output is correct |
13 | Correct | 37 ms | 43384 KB | Output is correct |
14 | Correct | 37 ms | 43512 KB | Output is correct |
15 | Correct | 31 ms | 43392 KB | Output is correct |
16 | Correct | 31 ms | 43392 KB | Output is correct |
17 | Correct | 33 ms | 43392 KB | Output is correct |
18 | Correct | 32 ms | 43384 KB | Output is correct |
19 | Correct | 31 ms | 43384 KB | Output is correct |
20 | Correct | 32 ms | 43392 KB | Output is correct |
21 | Correct | 34 ms | 43392 KB | Output is correct |
22 | Correct | 31 ms | 43392 KB | Output is correct |
23 | Correct | 32 ms | 43384 KB | Output is correct |
24 | Correct | 33 ms | 43392 KB | Output is correct |
25 | Correct | 32 ms | 43392 KB | Output is correct |
26 | Correct | 62 ms | 45416 KB | Output is correct |
27 | Correct | 83 ms | 46344 KB | Output is correct |
28 | Correct | 60 ms | 45364 KB | Output is correct |
29 | Correct | 88 ms | 46200 KB | Output is correct |
30 | Correct | 70 ms | 45336 KB | Output is correct |
31 | Correct | 97 ms | 47352 KB | Output is correct |
32 | Correct | 84 ms | 47352 KB | Output is correct |
33 | Correct | 92 ms | 47352 KB | Output is correct |
34 | Correct | 91 ms | 47736 KB | Output is correct |
35 | Correct | 82 ms | 47352 KB | Output is correct |
36 | Correct | 92 ms | 47480 KB | Output is correct |
37 | Correct | 90 ms | 47352 KB | Output is correct |
38 | Correct | 92 ms | 47352 KB | Output is correct |
39 | Correct | 88 ms | 47480 KB | Output is correct |
40 | Correct | 109 ms | 47736 KB | Output is correct |
41 | Correct | 73 ms | 45304 KB | Output is correct |
42 | Correct | 85 ms | 46456 KB | Output is correct |
43 | Correct | 80 ms | 46456 KB | Output is correct |
44 | Correct | 60 ms | 45304 KB | Output is correct |
45 | Correct | 79 ms | 46328 KB | Output is correct |
46 | Correct | 60 ms | 45304 KB | Output is correct |
47 | Correct | 92 ms | 46204 KB | Output is correct |
48 | Correct | 79 ms | 45432 KB | Output is correct |
49 | Correct | 76 ms | 46200 KB | Output is correct |
50 | Correct | 62 ms | 45432 KB | Output is correct |
51 | Correct | 98 ms | 46328 KB | Output is correct |
52 | Correct | 131 ms | 46888 KB | Output is correct |
53 | Correct | 94 ms | 46200 KB | Output is correct |
54 | Correct | 109 ms | 46968 KB | Output is correct |
55 | Correct | 104 ms | 46200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 43392 KB | Output is correct |
2 | Correct | 36 ms | 43392 KB | Output is correct |
3 | Correct | 30 ms | 43392 KB | Output is correct |
4 | Correct | 31 ms | 43392 KB | Output is correct |
5 | Correct | 31 ms | 43384 KB | Output is correct |
6 | Correct | 31 ms | 43392 KB | Output is correct |
7 | Correct | 31 ms | 43392 KB | Output is correct |
8 | Correct | 31 ms | 43392 KB | Output is correct |
9 | Correct | 31 ms | 43392 KB | Output is correct |
10 | Correct | 31 ms | 43392 KB | Output is correct |
11 | Correct | 31 ms | 43416 KB | Output is correct |
12 | Correct | 31 ms | 43392 KB | Output is correct |
13 | Correct | 37 ms | 43384 KB | Output is correct |
14 | Correct | 37 ms | 43512 KB | Output is correct |
15 | Correct | 31 ms | 43392 KB | Output is correct |
16 | Correct | 31 ms | 43392 KB | Output is correct |
17 | Correct | 33 ms | 43392 KB | Output is correct |
18 | Correct | 32 ms | 43384 KB | Output is correct |
19 | Correct | 31 ms | 43384 KB | Output is correct |
20 | Correct | 32 ms | 43392 KB | Output is correct |
21 | Correct | 34 ms | 43392 KB | Output is correct |
22 | Correct | 31 ms | 43392 KB | Output is correct |
23 | Correct | 32 ms | 43384 KB | Output is correct |
24 | Correct | 33 ms | 43392 KB | Output is correct |
25 | Correct | 32 ms | 43392 KB | Output is correct |
26 | Correct | 62 ms | 45416 KB | Output is correct |
27 | Correct | 83 ms | 46344 KB | Output is correct |
28 | Correct | 60 ms | 45364 KB | Output is correct |
29 | Correct | 88 ms | 46200 KB | Output is correct |
30 | Correct | 70 ms | 45336 KB | Output is correct |
31 | Correct | 97 ms | 47352 KB | Output is correct |
32 | Correct | 84 ms | 47352 KB | Output is correct |
33 | Correct | 92 ms | 47352 KB | Output is correct |
34 | Correct | 91 ms | 47736 KB | Output is correct |
35 | Correct | 82 ms | 47352 KB | Output is correct |
36 | Correct | 92 ms | 47480 KB | Output is correct |
37 | Correct | 90 ms | 47352 KB | Output is correct |
38 | Correct | 92 ms | 47352 KB | Output is correct |
39 | Correct | 88 ms | 47480 KB | Output is correct |
40 | Correct | 109 ms | 47736 KB | Output is correct |
41 | Correct | 73 ms | 45304 KB | Output is correct |
42 | Correct | 85 ms | 46456 KB | Output is correct |
43 | Correct | 80 ms | 46456 KB | Output is correct |
44 | Correct | 60 ms | 45304 KB | Output is correct |
45 | Correct | 79 ms | 46328 KB | Output is correct |
46 | Correct | 60 ms | 45304 KB | Output is correct |
47 | Correct | 92 ms | 46204 KB | Output is correct |
48 | Correct | 79 ms | 45432 KB | Output is correct |
49 | Correct | 76 ms | 46200 KB | Output is correct |
50 | Correct | 62 ms | 45432 KB | Output is correct |
51 | Correct | 98 ms | 46328 KB | Output is correct |
52 | Correct | 131 ms | 46888 KB | Output is correct |
53 | Correct | 94 ms | 46200 KB | Output is correct |
54 | Correct | 109 ms | 46968 KB | Output is correct |
55 | Correct | 104 ms | 46200 KB | Output is correct |
56 | Execution timed out | 1105 ms | 70524 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |