# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
894913 | 2023-12-29T08:12:05 Z | adkjt | Pilot (NOI19_pilot) | C++14 | 582 ms | 100644 KB |
#include<bits/stdc++.h> using namespace std; #define f first #define s second #define ll long long vector<int> g[1111111]; int a[1111111],vis[1111111],l[1111111],r[1111111]; long long ans[1111111],ind[1111111]; int main() { int n,q,hmx=0; scanf("%d %d",&n,&q); for(int i=1;i<=n;i++) ind[i]=ind[i-1]+i; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); hmx=max(hmx,a[i]); g[a[i]].push_back(i); } //s.insert({0,0}); for(int i=1;i<=hmx;i++) { ans[i]=ans[i-1]; for(auto x:g[i]) { if(!vis[x-1]&&!vis[x+1]) { vis[x]++; l[x]=x,r[x]=x; ans[i]++; } else if(vis[x-1]&&!vis[x+1]) { vis[x]++; l[x]=l[x-1]; r[x]=x; r[l[x-1]]=r[x]; ans[i]-=ind[x-l[x]]; ans[i]+=ind[x-l[x]+1]; } else if(!vis[x-1]&&vis[x+1]) { vis[x]++; l[x]=x; r[x]=r[x+1]; l[r[x+1]]=l[x]; ans[i]-=ind[r[x]-x]; ans[i]+=ind[r[x]-x+1]; } else if(vis[x-1]&&vis[x+1]) { vis[x]++; l[x]=l[x-1]; r[x]=r[x+1]; l[r[x+1]]=l[x]; r[l[x-1]]=r[x]; ans[i]-=ind[x-l[x]]; ans[i]-=ind[r[x]-x]; ans[i]+=ind[r[x]-l[x]+1]; //printf("%lld %lld %lld\n",ind[x-l[x]],ind[r[x]-x],ind[r[x]-l[x]+1]); } } } for(int i=1;i<=q;i++) { int qu; scanf("%d",&qu); if(qu>hmx) qu=hmx; printf("%lld\n",ans[qu]); } /*for(int i=1;i<=hmx;i++) printf("%lld ",ans[i]);*/ return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 34392 KB | Output is correct |
2 | Correct | 10 ms | 38236 KB | Output is correct |
3 | Correct | 11 ms | 42332 KB | Output is correct |
4 | Correct | 7 ms | 34396 KB | Output is correct |
5 | Correct | 10 ms | 42332 KB | Output is correct |
6 | Correct | 7 ms | 34268 KB | Output is correct |
7 | Correct | 10 ms | 42332 KB | Output is correct |
8 | Correct | 7 ms | 34648 KB | Output is correct |
9 | Correct | 10 ms | 40304 KB | Output is correct |
10 | Correct | 7 ms | 34396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 34392 KB | Output is correct |
2 | Correct | 10 ms | 38236 KB | Output is correct |
3 | Correct | 11 ms | 42332 KB | Output is correct |
4 | Correct | 7 ms | 34396 KB | Output is correct |
5 | Correct | 10 ms | 42332 KB | Output is correct |
6 | Correct | 7 ms | 34268 KB | Output is correct |
7 | Correct | 10 ms | 42332 KB | Output is correct |
8 | Correct | 7 ms | 34648 KB | Output is correct |
9 | Correct | 10 ms | 40304 KB | Output is correct |
10 | Correct | 7 ms | 34396 KB | Output is correct |
11 | Correct | 7 ms | 34476 KB | Output is correct |
12 | Correct | 10 ms | 42332 KB | Output is correct |
13 | Correct | 7 ms | 34252 KB | Output is correct |
14 | Correct | 11 ms | 42584 KB | Output is correct |
15 | Correct | 7 ms | 34480 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 34392 KB | Output is correct |
2 | Correct | 10 ms | 38236 KB | Output is correct |
3 | Correct | 11 ms | 42332 KB | Output is correct |
4 | Correct | 7 ms | 34396 KB | Output is correct |
5 | Correct | 10 ms | 42332 KB | Output is correct |
6 | Correct | 7 ms | 34268 KB | Output is correct |
7 | Correct | 10 ms | 42332 KB | Output is correct |
8 | Correct | 7 ms | 34648 KB | Output is correct |
9 | Correct | 10 ms | 40304 KB | Output is correct |
10 | Correct | 7 ms | 34396 KB | Output is correct |
11 | Correct | 7 ms | 34476 KB | Output is correct |
12 | Correct | 10 ms | 42332 KB | Output is correct |
13 | Correct | 7 ms | 34252 KB | Output is correct |
14 | Correct | 11 ms | 42584 KB | Output is correct |
15 | Correct | 7 ms | 34480 KB | Output is correct |
16 | Correct | 7 ms | 34396 KB | Output is correct |
17 | Correct | 11 ms | 42332 KB | Output is correct |
18 | Correct | 7 ms | 34268 KB | Output is correct |
19 | Correct | 10 ms | 42332 KB | Output is correct |
20 | Correct | 7 ms | 34396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 34392 KB | Output is correct |
2 | Correct | 10 ms | 38236 KB | Output is correct |
3 | Correct | 11 ms | 42332 KB | Output is correct |
4 | Correct | 7 ms | 34396 KB | Output is correct |
5 | Correct | 10 ms | 42332 KB | Output is correct |
6 | Correct | 7 ms | 34268 KB | Output is correct |
7 | Correct | 10 ms | 42332 KB | Output is correct |
8 | Correct | 7 ms | 34648 KB | Output is correct |
9 | Correct | 10 ms | 40304 KB | Output is correct |
10 | Correct | 7 ms | 34396 KB | Output is correct |
11 | Correct | 7 ms | 34476 KB | Output is correct |
12 | Correct | 10 ms | 42332 KB | Output is correct |
13 | Correct | 7 ms | 34252 KB | Output is correct |
14 | Correct | 11 ms | 42584 KB | Output is correct |
15 | Correct | 7 ms | 34480 KB | Output is correct |
16 | Correct | 7 ms | 34396 KB | Output is correct |
17 | Correct | 11 ms | 42332 KB | Output is correct |
18 | Correct | 7 ms | 34268 KB | Output is correct |
19 | Correct | 10 ms | 42332 KB | Output is correct |
20 | Correct | 7 ms | 34396 KB | Output is correct |
21 | Correct | 7 ms | 34396 KB | Output is correct |
22 | Correct | 11 ms | 42212 KB | Output is correct |
23 | Correct | 8 ms | 34396 KB | Output is correct |
24 | Correct | 12 ms | 42328 KB | Output is correct |
25 | Correct | 8 ms | 34648 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 39940 KB | Output is correct |
2 | Correct | 46 ms | 47700 KB | Output is correct |
3 | Correct | 33 ms | 39504 KB | Output is correct |
4 | Correct | 38 ms | 47444 KB | Output is correct |
5 | Correct | 28 ms | 39572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 41900 KB | Output is correct |
2 | Correct | 42 ms | 41808 KB | Output is correct |
3 | Correct | 39 ms | 41404 KB | Output is correct |
4 | Correct | 40 ms | 41816 KB | Output is correct |
5 | Correct | 39 ms | 41552 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 48880 KB | Output is correct |
2 | Correct | 49 ms | 48844 KB | Output is correct |
3 | Correct | 61 ms | 48720 KB | Output is correct |
4 | Correct | 48 ms | 49060 KB | Output is correct |
5 | Correct | 52 ms | 48776 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 34392 KB | Output is correct |
2 | Correct | 10 ms | 38236 KB | Output is correct |
3 | Correct | 11 ms | 42332 KB | Output is correct |
4 | Correct | 7 ms | 34396 KB | Output is correct |
5 | Correct | 10 ms | 42332 KB | Output is correct |
6 | Correct | 7 ms | 34268 KB | Output is correct |
7 | Correct | 10 ms | 42332 KB | Output is correct |
8 | Correct | 7 ms | 34648 KB | Output is correct |
9 | Correct | 10 ms | 40304 KB | Output is correct |
10 | Correct | 7 ms | 34396 KB | Output is correct |
11 | Correct | 30 ms | 39940 KB | Output is correct |
12 | Correct | 46 ms | 47700 KB | Output is correct |
13 | Correct | 33 ms | 39504 KB | Output is correct |
14 | Correct | 38 ms | 47444 KB | Output is correct |
15 | Correct | 28 ms | 39572 KB | Output is correct |
16 | Correct | 25 ms | 39508 KB | Output is correct |
17 | Correct | 43 ms | 47704 KB | Output is correct |
18 | Correct | 44 ms | 47696 KB | Output is correct |
19 | Correct | 29 ms | 39516 KB | Output is correct |
20 | Correct | 40 ms | 47644 KB | Output is correct |
21 | Correct | 25 ms | 39516 KB | Output is correct |
22 | Correct | 42 ms | 47708 KB | Output is correct |
23 | Correct | 26 ms | 39772 KB | Output is correct |
24 | Correct | 38 ms | 47440 KB | Output is correct |
25 | Correct | 26 ms | 39644 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 34392 KB | Output is correct |
2 | Correct | 10 ms | 38236 KB | Output is correct |
3 | Correct | 11 ms | 42332 KB | Output is correct |
4 | Correct | 7 ms | 34396 KB | Output is correct |
5 | Correct | 10 ms | 42332 KB | Output is correct |
6 | Correct | 7 ms | 34268 KB | Output is correct |
7 | Correct | 10 ms | 42332 KB | Output is correct |
8 | Correct | 7 ms | 34648 KB | Output is correct |
9 | Correct | 10 ms | 40304 KB | Output is correct |
10 | Correct | 7 ms | 34396 KB | Output is correct |
11 | Correct | 7 ms | 34476 KB | Output is correct |
12 | Correct | 10 ms | 42332 KB | Output is correct |
13 | Correct | 7 ms | 34252 KB | Output is correct |
14 | Correct | 11 ms | 42584 KB | Output is correct |
15 | Correct | 7 ms | 34480 KB | Output is correct |
16 | Correct | 7 ms | 34396 KB | Output is correct |
17 | Correct | 11 ms | 42332 KB | Output is correct |
18 | Correct | 7 ms | 34268 KB | Output is correct |
19 | Correct | 10 ms | 42332 KB | Output is correct |
20 | Correct | 7 ms | 34396 KB | Output is correct |
21 | Correct | 7 ms | 34396 KB | Output is correct |
22 | Correct | 11 ms | 42212 KB | Output is correct |
23 | Correct | 8 ms | 34396 KB | Output is correct |
24 | Correct | 12 ms | 42328 KB | Output is correct |
25 | Correct | 8 ms | 34648 KB | Output is correct |
26 | Correct | 30 ms | 39940 KB | Output is correct |
27 | Correct | 46 ms | 47700 KB | Output is correct |
28 | Correct | 33 ms | 39504 KB | Output is correct |
29 | Correct | 38 ms | 47444 KB | Output is correct |
30 | Correct | 28 ms | 39572 KB | Output is correct |
31 | Correct | 39 ms | 41900 KB | Output is correct |
32 | Correct | 42 ms | 41808 KB | Output is correct |
33 | Correct | 39 ms | 41404 KB | Output is correct |
34 | Correct | 40 ms | 41816 KB | Output is correct |
35 | Correct | 39 ms | 41552 KB | Output is correct |
36 | Correct | 48 ms | 48880 KB | Output is correct |
37 | Correct | 49 ms | 48844 KB | Output is correct |
38 | Correct | 61 ms | 48720 KB | Output is correct |
39 | Correct | 48 ms | 49060 KB | Output is correct |
40 | Correct | 52 ms | 48776 KB | Output is correct |
41 | Correct | 25 ms | 39508 KB | Output is correct |
42 | Correct | 43 ms | 47704 KB | Output is correct |
43 | Correct | 44 ms | 47696 KB | Output is correct |
44 | Correct | 29 ms | 39516 KB | Output is correct |
45 | Correct | 40 ms | 47644 KB | Output is correct |
46 | Correct | 25 ms | 39516 KB | Output is correct |
47 | Correct | 42 ms | 47708 KB | Output is correct |
48 | Correct | 26 ms | 39772 KB | Output is correct |
49 | Correct | 38 ms | 47440 KB | Output is correct |
50 | Correct | 26 ms | 39644 KB | Output is correct |
51 | Correct | 46 ms | 40516 KB | Output is correct |
52 | Correct | 65 ms | 48208 KB | Output is correct |
53 | Correct | 44 ms | 40528 KB | Output is correct |
54 | Correct | 64 ms | 48208 KB | Output is correct |
55 | Correct | 43 ms | 40360 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 34392 KB | Output is correct |
2 | Correct | 10 ms | 38236 KB | Output is correct |
3 | Correct | 11 ms | 42332 KB | Output is correct |
4 | Correct | 7 ms | 34396 KB | Output is correct |
5 | Correct | 10 ms | 42332 KB | Output is correct |
6 | Correct | 7 ms | 34268 KB | Output is correct |
7 | Correct | 10 ms | 42332 KB | Output is correct |
8 | Correct | 7 ms | 34648 KB | Output is correct |
9 | Correct | 10 ms | 40304 KB | Output is correct |
10 | Correct | 7 ms | 34396 KB | Output is correct |
11 | Correct | 7 ms | 34476 KB | Output is correct |
12 | Correct | 10 ms | 42332 KB | Output is correct |
13 | Correct | 7 ms | 34252 KB | Output is correct |
14 | Correct | 11 ms | 42584 KB | Output is correct |
15 | Correct | 7 ms | 34480 KB | Output is correct |
16 | Correct | 7 ms | 34396 KB | Output is correct |
17 | Correct | 11 ms | 42332 KB | Output is correct |
18 | Correct | 7 ms | 34268 KB | Output is correct |
19 | Correct | 10 ms | 42332 KB | Output is correct |
20 | Correct | 7 ms | 34396 KB | Output is correct |
21 | Correct | 7 ms | 34396 KB | Output is correct |
22 | Correct | 11 ms | 42212 KB | Output is correct |
23 | Correct | 8 ms | 34396 KB | Output is correct |
24 | Correct | 12 ms | 42328 KB | Output is correct |
25 | Correct | 8 ms | 34648 KB | Output is correct |
26 | Correct | 30 ms | 39940 KB | Output is correct |
27 | Correct | 46 ms | 47700 KB | Output is correct |
28 | Correct | 33 ms | 39504 KB | Output is correct |
29 | Correct | 38 ms | 47444 KB | Output is correct |
30 | Correct | 28 ms | 39572 KB | Output is correct |
31 | Correct | 39 ms | 41900 KB | Output is correct |
32 | Correct | 42 ms | 41808 KB | Output is correct |
33 | Correct | 39 ms | 41404 KB | Output is correct |
34 | Correct | 40 ms | 41816 KB | Output is correct |
35 | Correct | 39 ms | 41552 KB | Output is correct |
36 | Correct | 48 ms | 48880 KB | Output is correct |
37 | Correct | 49 ms | 48844 KB | Output is correct |
38 | Correct | 61 ms | 48720 KB | Output is correct |
39 | Correct | 48 ms | 49060 KB | Output is correct |
40 | Correct | 52 ms | 48776 KB | Output is correct |
41 | Correct | 25 ms | 39508 KB | Output is correct |
42 | Correct | 43 ms | 47704 KB | Output is correct |
43 | Correct | 44 ms | 47696 KB | Output is correct |
44 | Correct | 29 ms | 39516 KB | Output is correct |
45 | Correct | 40 ms | 47644 KB | Output is correct |
46 | Correct | 25 ms | 39516 KB | Output is correct |
47 | Correct | 42 ms | 47708 KB | Output is correct |
48 | Correct | 26 ms | 39772 KB | Output is correct |
49 | Correct | 38 ms | 47440 KB | Output is correct |
50 | Correct | 26 ms | 39644 KB | Output is correct |
51 | Correct | 46 ms | 40516 KB | Output is correct |
52 | Correct | 65 ms | 48208 KB | Output is correct |
53 | Correct | 44 ms | 40528 KB | Output is correct |
54 | Correct | 64 ms | 48208 KB | Output is correct |
55 | Correct | 43 ms | 40360 KB | Output is correct |
56 | Correct | 542 ms | 88664 KB | Output is correct |
57 | Correct | 558 ms | 99920 KB | Output is correct |
58 | Correct | 502 ms | 97436 KB | Output is correct |
59 | Correct | 551 ms | 98996 KB | Output is correct |
60 | Correct | 582 ms | 100644 KB | Output is correct |