# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224567 | 2020-04-18T12:37:15 Z | kshitij_sodani | Pilot (NOI19_pilot) | C++17 | 1000 ms | 111400 KB |
#include <iostream> #include <bits/stdc++.h> using namespace std; #define a first #define b second #define pb push_back typedef long long llo; llo par[1000001]; llo ss[1000001]; vector<llo> it[1000001]; vector<llo> tt[1000001]; llo find(llo no){ if(par[no]==no){ return no; } par[no]=find(par[no]); return par[no]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); llo n,q; cin>>n>>q; for(llo i=0;i<n;i++){ par[i]=i; ss[i]=0; } llo aa; for(llo i=0;i<n;i++){ cin>>aa; it[aa].pb(i); } llo ans2[q]; for(llo i=0;i<q;i++){ cin>>aa; tt[aa].pb(i); } llo ans=0; for(llo k=0;k<1000001;k++){ for(llo j=0;j<it[k].size();j++){ llo ind=it[k][j]; ss[ind]=1; ans+=1; if(ind>0){ if(ss[ind-1]>0){ llo x=find(ind-1); ans+=ss[x]; ss[x]+=ss[ind]; par[ind]=x; } } if(ind<n-1){ if(ss[ind+1]>0){ llo y=find(ind); llo x=find(ind+1); if(ss[x]>ss[y]){ ans+=ss[x]*ss[y]; ss[x]+=ss[y]; par[y]=x; } else{ ans+=ss[x]*ss[y]; ss[y]+=ss[x]; par[x]=y; } } } } for(int j=0;j<tt[k].size();j++){ ans2[tt[k][j]]=ans; } } for(llo i=0;i<q;i++){ cout<<ans2[i]<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 47360 KB | Output is correct |
2 | Correct | 38 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47360 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 39 ms | 47360 KB | Output is correct |
6 | Correct | 32 ms | 47360 KB | Output is correct |
7 | Correct | 33 ms | 47360 KB | Output is correct |
8 | Correct | 33 ms | 47360 KB | Output is correct |
9 | Correct | 38 ms | 47480 KB | Output is correct |
10 | Correct | 45 ms | 47360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 47360 KB | Output is correct |
2 | Correct | 38 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47360 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 39 ms | 47360 KB | Output is correct |
6 | Correct | 32 ms | 47360 KB | Output is correct |
7 | Correct | 33 ms | 47360 KB | Output is correct |
8 | Correct | 33 ms | 47360 KB | Output is correct |
9 | Correct | 38 ms | 47480 KB | Output is correct |
10 | Correct | 45 ms | 47360 KB | Output is correct |
11 | Correct | 33 ms | 47268 KB | Output is correct |
12 | Correct | 42 ms | 47360 KB | Output is correct |
13 | Correct | 33 ms | 47360 KB | Output is correct |
14 | Correct | 37 ms | 47360 KB | Output is correct |
15 | Correct | 35 ms | 47360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 47360 KB | Output is correct |
2 | Correct | 38 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47360 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 39 ms | 47360 KB | Output is correct |
6 | Correct | 32 ms | 47360 KB | Output is correct |
7 | Correct | 33 ms | 47360 KB | Output is correct |
8 | Correct | 33 ms | 47360 KB | Output is correct |
9 | Correct | 38 ms | 47480 KB | Output is correct |
10 | Correct | 45 ms | 47360 KB | Output is correct |
11 | Correct | 33 ms | 47268 KB | Output is correct |
12 | Correct | 42 ms | 47360 KB | Output is correct |
13 | Correct | 33 ms | 47360 KB | Output is correct |
14 | Correct | 37 ms | 47360 KB | Output is correct |
15 | Correct | 35 ms | 47360 KB | Output is correct |
16 | Correct | 34 ms | 47360 KB | Output is correct |
17 | Correct | 34 ms | 47360 KB | Output is correct |
18 | Correct | 35 ms | 47360 KB | Output is correct |
19 | Correct | 35 ms | 47360 KB | Output is correct |
20 | Correct | 33 ms | 47360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 47360 KB | Output is correct |
2 | Correct | 38 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47360 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 39 ms | 47360 KB | Output is correct |
6 | Correct | 32 ms | 47360 KB | Output is correct |
7 | Correct | 33 ms | 47360 KB | Output is correct |
8 | Correct | 33 ms | 47360 KB | Output is correct |
9 | Correct | 38 ms | 47480 KB | Output is correct |
10 | Correct | 45 ms | 47360 KB | Output is correct |
11 | Correct | 33 ms | 47268 KB | Output is correct |
12 | Correct | 42 ms | 47360 KB | Output is correct |
13 | Correct | 33 ms | 47360 KB | Output is correct |
14 | Correct | 37 ms | 47360 KB | Output is correct |
15 | Correct | 35 ms | 47360 KB | Output is correct |
16 | Correct | 34 ms | 47360 KB | Output is correct |
17 | Correct | 34 ms | 47360 KB | Output is correct |
18 | Correct | 35 ms | 47360 KB | Output is correct |
19 | Correct | 35 ms | 47360 KB | Output is correct |
20 | Correct | 33 ms | 47360 KB | Output is correct |
21 | Correct | 36 ms | 47360 KB | Output is correct |
22 | Correct | 39 ms | 47352 KB | Output is correct |
23 | Correct | 36 ms | 47360 KB | Output is correct |
24 | Correct | 37 ms | 47360 KB | Output is correct |
25 | Correct | 39 ms | 47360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 60 ms | 51064 KB | Output is correct |
2 | Correct | 77 ms | 51960 KB | Output is correct |
3 | Correct | 58 ms | 50936 KB | Output is correct |
4 | Correct | 83 ms | 51704 KB | Output is correct |
5 | Correct | 60 ms | 50936 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 274 ms | 56184 KB | Output is correct |
2 | Correct | 270 ms | 56360 KB | Output is correct |
3 | Correct | 281 ms | 56184 KB | Output is correct |
4 | Correct | 267 ms | 56320 KB | Output is correct |
5 | Correct | 278 ms | 56056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 268 ms | 56360 KB | Output is correct |
2 | Correct | 281 ms | 56440 KB | Output is correct |
3 | Correct | 280 ms | 56312 KB | Output is correct |
4 | Correct | 274 ms | 56568 KB | Output is correct |
5 | Correct | 288 ms | 56568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 47360 KB | Output is correct |
2 | Correct | 38 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47360 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 39 ms | 47360 KB | Output is correct |
6 | Correct | 32 ms | 47360 KB | Output is correct |
7 | Correct | 33 ms | 47360 KB | Output is correct |
8 | Correct | 33 ms | 47360 KB | Output is correct |
9 | Correct | 38 ms | 47480 KB | Output is correct |
10 | Correct | 45 ms | 47360 KB | Output is correct |
11 | Correct | 60 ms | 51064 KB | Output is correct |
12 | Correct | 77 ms | 51960 KB | Output is correct |
13 | Correct | 58 ms | 50936 KB | Output is correct |
14 | Correct | 83 ms | 51704 KB | Output is correct |
15 | Correct | 60 ms | 50936 KB | Output is correct |
16 | Correct | 57 ms | 50936 KB | Output is correct |
17 | Correct | 83 ms | 51960 KB | Output is correct |
18 | Correct | 78 ms | 52088 KB | Output is correct |
19 | Correct | 63 ms | 50936 KB | Output is correct |
20 | Correct | 77 ms | 51832 KB | Output is correct |
21 | Correct | 58 ms | 50936 KB | Output is correct |
22 | Correct | 78 ms | 51832 KB | Output is correct |
23 | Correct | 61 ms | 51192 KB | Output is correct |
24 | Correct | 73 ms | 51704 KB | Output is correct |
25 | Correct | 60 ms | 51064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 47360 KB | Output is correct |
2 | Correct | 38 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47360 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 39 ms | 47360 KB | Output is correct |
6 | Correct | 32 ms | 47360 KB | Output is correct |
7 | Correct | 33 ms | 47360 KB | Output is correct |
8 | Correct | 33 ms | 47360 KB | Output is correct |
9 | Correct | 38 ms | 47480 KB | Output is correct |
10 | Correct | 45 ms | 47360 KB | Output is correct |
11 | Correct | 33 ms | 47268 KB | Output is correct |
12 | Correct | 42 ms | 47360 KB | Output is correct |
13 | Correct | 33 ms | 47360 KB | Output is correct |
14 | Correct | 37 ms | 47360 KB | Output is correct |
15 | Correct | 35 ms | 47360 KB | Output is correct |
16 | Correct | 34 ms | 47360 KB | Output is correct |
17 | Correct | 34 ms | 47360 KB | Output is correct |
18 | Correct | 35 ms | 47360 KB | Output is correct |
19 | Correct | 35 ms | 47360 KB | Output is correct |
20 | Correct | 33 ms | 47360 KB | Output is correct |
21 | Correct | 36 ms | 47360 KB | Output is correct |
22 | Correct | 39 ms | 47352 KB | Output is correct |
23 | Correct | 36 ms | 47360 KB | Output is correct |
24 | Correct | 37 ms | 47360 KB | Output is correct |
25 | Correct | 39 ms | 47360 KB | Output is correct |
26 | Correct | 60 ms | 51064 KB | Output is correct |
27 | Correct | 77 ms | 51960 KB | Output is correct |
28 | Correct | 58 ms | 50936 KB | Output is correct |
29 | Correct | 83 ms | 51704 KB | Output is correct |
30 | Correct | 60 ms | 50936 KB | Output is correct |
31 | Correct | 274 ms | 56184 KB | Output is correct |
32 | Correct | 270 ms | 56360 KB | Output is correct |
33 | Correct | 281 ms | 56184 KB | Output is correct |
34 | Correct | 267 ms | 56320 KB | Output is correct |
35 | Correct | 278 ms | 56056 KB | Output is correct |
36 | Correct | 268 ms | 56360 KB | Output is correct |
37 | Correct | 281 ms | 56440 KB | Output is correct |
38 | Correct | 280 ms | 56312 KB | Output is correct |
39 | Correct | 274 ms | 56568 KB | Output is correct |
40 | Correct | 288 ms | 56568 KB | Output is correct |
41 | Correct | 57 ms | 50936 KB | Output is correct |
42 | Correct | 83 ms | 51960 KB | Output is correct |
43 | Correct | 78 ms | 52088 KB | Output is correct |
44 | Correct | 63 ms | 50936 KB | Output is correct |
45 | Correct | 77 ms | 51832 KB | Output is correct |
46 | Correct | 58 ms | 50936 KB | Output is correct |
47 | Correct | 78 ms | 51832 KB | Output is correct |
48 | Correct | 61 ms | 51192 KB | Output is correct |
49 | Correct | 73 ms | 51704 KB | Output is correct |
50 | Correct | 60 ms | 51064 KB | Output is correct |
51 | Correct | 288 ms | 55160 KB | Output is correct |
52 | Correct | 306 ms | 55928 KB | Output is correct |
53 | Correct | 281 ms | 55160 KB | Output is correct |
54 | Correct | 297 ms | 55976 KB | Output is correct |
55 | Correct | 280 ms | 55160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 47360 KB | Output is correct |
2 | Correct | 38 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47360 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 39 ms | 47360 KB | Output is correct |
6 | Correct | 32 ms | 47360 KB | Output is correct |
7 | Correct | 33 ms | 47360 KB | Output is correct |
8 | Correct | 33 ms | 47360 KB | Output is correct |
9 | Correct | 38 ms | 47480 KB | Output is correct |
10 | Correct | 45 ms | 47360 KB | Output is correct |
11 | Correct | 33 ms | 47268 KB | Output is correct |
12 | Correct | 42 ms | 47360 KB | Output is correct |
13 | Correct | 33 ms | 47360 KB | Output is correct |
14 | Correct | 37 ms | 47360 KB | Output is correct |
15 | Correct | 35 ms | 47360 KB | Output is correct |
16 | Correct | 34 ms | 47360 KB | Output is correct |
17 | Correct | 34 ms | 47360 KB | Output is correct |
18 | Correct | 35 ms | 47360 KB | Output is correct |
19 | Correct | 35 ms | 47360 KB | Output is correct |
20 | Correct | 33 ms | 47360 KB | Output is correct |
21 | Correct | 36 ms | 47360 KB | Output is correct |
22 | Correct | 39 ms | 47352 KB | Output is correct |
23 | Correct | 36 ms | 47360 KB | Output is correct |
24 | Correct | 37 ms | 47360 KB | Output is correct |
25 | Correct | 39 ms | 47360 KB | Output is correct |
26 | Correct | 60 ms | 51064 KB | Output is correct |
27 | Correct | 77 ms | 51960 KB | Output is correct |
28 | Correct | 58 ms | 50936 KB | Output is correct |
29 | Correct | 83 ms | 51704 KB | Output is correct |
30 | Correct | 60 ms | 50936 KB | Output is correct |
31 | Correct | 274 ms | 56184 KB | Output is correct |
32 | Correct | 270 ms | 56360 KB | Output is correct |
33 | Correct | 281 ms | 56184 KB | Output is correct |
34 | Correct | 267 ms | 56320 KB | Output is correct |
35 | Correct | 278 ms | 56056 KB | Output is correct |
36 | Correct | 268 ms | 56360 KB | Output is correct |
37 | Correct | 281 ms | 56440 KB | Output is correct |
38 | Correct | 280 ms | 56312 KB | Output is correct |
39 | Correct | 274 ms | 56568 KB | Output is correct |
40 | Correct | 288 ms | 56568 KB | Output is correct |
41 | Correct | 57 ms | 50936 KB | Output is correct |
42 | Correct | 83 ms | 51960 KB | Output is correct |
43 | Correct | 78 ms | 52088 KB | Output is correct |
44 | Correct | 63 ms | 50936 KB | Output is correct |
45 | Correct | 77 ms | 51832 KB | Output is correct |
46 | Correct | 58 ms | 50936 KB | Output is correct |
47 | Correct | 78 ms | 51832 KB | Output is correct |
48 | Correct | 61 ms | 51192 KB | Output is correct |
49 | Correct | 73 ms | 51704 KB | Output is correct |
50 | Correct | 60 ms | 51064 KB | Output is correct |
51 | Correct | 288 ms | 55160 KB | Output is correct |
52 | Correct | 306 ms | 55928 KB | Output is correct |
53 | Correct | 281 ms | 55160 KB | Output is correct |
54 | Correct | 297 ms | 55976 KB | Output is correct |
55 | Correct | 280 ms | 55160 KB | Output is correct |
56 | Execution timed out | 1097 ms | 111400 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |