# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471539 | 2021-09-09T16:57:33 Z | jazzup | Pilot (NOI19_pilot) | C++14 | 1000 ms | 57480 KB |
/*input 6 3 1 3 2 4 1 2 2 3 4 */ //NOI-SG 2019 #include<cstdio> #include<algorithm> #include<set> #include<vector> using namespace std; long long ans[1000007]; pair<int,int> a[1000007]; set<int> b; int main(){ long long n,q,y; set<int>::iterator it; scanf("%lld%lld",&n,&q); for(int i=0;i<n;i++){ scanf("%d",&a[i].first); a[i].second=i+1; } sort(a,a+n); long long cur= (n*(n-1))/2 + n; int idx=n-1; b.insert(0); b.insert(n+1); for(int i=1000000;i>0;i--){ while(i<a[idx].first){ it=b.lower_bound(a[idx].second); long long r=*it; it--; long long l=*it; long long diff=r-l-1; cur-=((diff*(diff-1))/2 + diff); diff=r-a[idx].second-1; cur+=((diff*(diff-1))/2 + diff); diff=a[idx].second-l-1; cur+=((diff*(diff-1))/2 + diff); b.insert(a[idx].second); idx--; if(idx<0){ break; } } if(idx<0)break; ans[i]=cur; } for(int i=0;i<q;i++){ scanf("%lld",&y); printf("%lld\n",ans[y]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8012 KB | Output is correct |
2 | Correct | 4 ms | 5068 KB | Output is correct |
3 | Correct | 4 ms | 6220 KB | Output is correct |
4 | Correct | 5 ms | 8012 KB | Output is correct |
5 | Correct | 3 ms | 4044 KB | Output is correct |
6 | Correct | 7 ms | 8012 KB | Output is correct |
7 | Correct | 3 ms | 4428 KB | Output is correct |
8 | Correct | 6 ms | 8012 KB | Output is correct |
9 | Correct | 3 ms | 3148 KB | Output is correct |
10 | Correct | 6 ms | 8012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8012 KB | Output is correct |
2 | Correct | 4 ms | 5068 KB | Output is correct |
3 | Correct | 4 ms | 6220 KB | Output is correct |
4 | Correct | 5 ms | 8012 KB | Output is correct |
5 | Correct | 3 ms | 4044 KB | Output is correct |
6 | Correct | 7 ms | 8012 KB | Output is correct |
7 | Correct | 3 ms | 4428 KB | Output is correct |
8 | Correct | 6 ms | 8012 KB | Output is correct |
9 | Correct | 3 ms | 3148 KB | Output is correct |
10 | Correct | 6 ms | 8012 KB | Output is correct |
11 | Correct | 5 ms | 8012 KB | Output is correct |
12 | Correct | 7 ms | 8012 KB | Output is correct |
13 | Correct | 5 ms | 8012 KB | Output is correct |
14 | Correct | 5 ms | 7572 KB | Output is correct |
15 | Correct | 7 ms | 8024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8012 KB | Output is correct |
2 | Correct | 4 ms | 5068 KB | Output is correct |
3 | Correct | 4 ms | 6220 KB | Output is correct |
4 | Correct | 5 ms | 8012 KB | Output is correct |
5 | Correct | 3 ms | 4044 KB | Output is correct |
6 | Correct | 7 ms | 8012 KB | Output is correct |
7 | Correct | 3 ms | 4428 KB | Output is correct |
8 | Correct | 6 ms | 8012 KB | Output is correct |
9 | Correct | 3 ms | 3148 KB | Output is correct |
10 | Correct | 6 ms | 8012 KB | Output is correct |
11 | Correct | 5 ms | 8012 KB | Output is correct |
12 | Correct | 7 ms | 8012 KB | Output is correct |
13 | Correct | 5 ms | 8012 KB | Output is correct |
14 | Correct | 5 ms | 7572 KB | Output is correct |
15 | Correct | 7 ms | 8024 KB | Output is correct |
16 | Correct | 6 ms | 8012 KB | Output is correct |
17 | Correct | 5 ms | 8012 KB | Output is correct |
18 | Correct | 7 ms | 8012 KB | Output is correct |
19 | Correct | 6 ms | 8012 KB | Output is correct |
20 | Correct | 6 ms | 8044 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8012 KB | Output is correct |
2 | Correct | 4 ms | 5068 KB | Output is correct |
3 | Correct | 4 ms | 6220 KB | Output is correct |
4 | Correct | 5 ms | 8012 KB | Output is correct |
5 | Correct | 3 ms | 4044 KB | Output is correct |
6 | Correct | 7 ms | 8012 KB | Output is correct |
7 | Correct | 3 ms | 4428 KB | Output is correct |
8 | Correct | 6 ms | 8012 KB | Output is correct |
9 | Correct | 3 ms | 3148 KB | Output is correct |
10 | Correct | 6 ms | 8012 KB | Output is correct |
11 | Correct | 5 ms | 8012 KB | Output is correct |
12 | Correct | 7 ms | 8012 KB | Output is correct |
13 | Correct | 5 ms | 8012 KB | Output is correct |
14 | Correct | 5 ms | 7572 KB | Output is correct |
15 | Correct | 7 ms | 8024 KB | Output is correct |
16 | Correct | 6 ms | 8012 KB | Output is correct |
17 | Correct | 5 ms | 8012 KB | Output is correct |
18 | Correct | 7 ms | 8012 KB | Output is correct |
19 | Correct | 6 ms | 8012 KB | Output is correct |
20 | Correct | 6 ms | 8044 KB | Output is correct |
21 | Correct | 6 ms | 8140 KB | Output is correct |
22 | Correct | 7 ms | 8140 KB | Output is correct |
23 | Correct | 6 ms | 8140 KB | Output is correct |
24 | Correct | 6 ms | 8104 KB | Output is correct |
25 | Correct | 6 ms | 8140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 13308 KB | Output is correct |
2 | Correct | 80 ms | 13456 KB | Output is correct |
3 | Correct | 66 ms | 13124 KB | Output is correct |
4 | Correct | 62 ms | 12920 KB | Output is correct |
5 | Correct | 65 ms | 13152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 14184 KB | Output is correct |
2 | Correct | 82 ms | 14196 KB | Output is correct |
3 | Correct | 80 ms | 14020 KB | Output is correct |
4 | Correct | 83 ms | 14276 KB | Output is correct |
5 | Correct | 80 ms | 13988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 84 ms | 14152 KB | Output is correct |
2 | Correct | 93 ms | 14048 KB | Output is correct |
3 | Correct | 87 ms | 13928 KB | Output is correct |
4 | Correct | 89 ms | 14484 KB | Output is correct |
5 | Correct | 84 ms | 14192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8012 KB | Output is correct |
2 | Correct | 4 ms | 5068 KB | Output is correct |
3 | Correct | 4 ms | 6220 KB | Output is correct |
4 | Correct | 5 ms | 8012 KB | Output is correct |
5 | Correct | 3 ms | 4044 KB | Output is correct |
6 | Correct | 7 ms | 8012 KB | Output is correct |
7 | Correct | 3 ms | 4428 KB | Output is correct |
8 | Correct | 6 ms | 8012 KB | Output is correct |
9 | Correct | 3 ms | 3148 KB | Output is correct |
10 | Correct | 6 ms | 8012 KB | Output is correct |
11 | Correct | 83 ms | 13308 KB | Output is correct |
12 | Correct | 80 ms | 13456 KB | Output is correct |
13 | Correct | 66 ms | 13124 KB | Output is correct |
14 | Correct | 62 ms | 12920 KB | Output is correct |
15 | Correct | 65 ms | 13152 KB | Output is correct |
16 | Correct | 61 ms | 13160 KB | Output is correct |
17 | Correct | 67 ms | 13400 KB | Output is correct |
18 | Correct | 76 ms | 13444 KB | Output is correct |
19 | Correct | 63 ms | 13020 KB | Output is correct |
20 | Correct | 75 ms | 13316 KB | Output is correct |
21 | Correct | 63 ms | 13096 KB | Output is correct |
22 | Correct | 64 ms | 13056 KB | Output is correct |
23 | Correct | 67 ms | 13452 KB | Output is correct |
24 | Correct | 62 ms | 12996 KB | Output is correct |
25 | Correct | 72 ms | 13472 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8012 KB | Output is correct |
2 | Correct | 4 ms | 5068 KB | Output is correct |
3 | Correct | 4 ms | 6220 KB | Output is correct |
4 | Correct | 5 ms | 8012 KB | Output is correct |
5 | Correct | 3 ms | 4044 KB | Output is correct |
6 | Correct | 7 ms | 8012 KB | Output is correct |
7 | Correct | 3 ms | 4428 KB | Output is correct |
8 | Correct | 6 ms | 8012 KB | Output is correct |
9 | Correct | 3 ms | 3148 KB | Output is correct |
10 | Correct | 6 ms | 8012 KB | Output is correct |
11 | Correct | 5 ms | 8012 KB | Output is correct |
12 | Correct | 7 ms | 8012 KB | Output is correct |
13 | Correct | 5 ms | 8012 KB | Output is correct |
14 | Correct | 5 ms | 7572 KB | Output is correct |
15 | Correct | 7 ms | 8024 KB | Output is correct |
16 | Correct | 6 ms | 8012 KB | Output is correct |
17 | Correct | 5 ms | 8012 KB | Output is correct |
18 | Correct | 7 ms | 8012 KB | Output is correct |
19 | Correct | 6 ms | 8012 KB | Output is correct |
20 | Correct | 6 ms | 8044 KB | Output is correct |
21 | Correct | 6 ms | 8140 KB | Output is correct |
22 | Correct | 7 ms | 8140 KB | Output is correct |
23 | Correct | 6 ms | 8140 KB | Output is correct |
24 | Correct | 6 ms | 8104 KB | Output is correct |
25 | Correct | 6 ms | 8140 KB | Output is correct |
26 | Correct | 83 ms | 13308 KB | Output is correct |
27 | Correct | 80 ms | 13456 KB | Output is correct |
28 | Correct | 66 ms | 13124 KB | Output is correct |
29 | Correct | 62 ms | 12920 KB | Output is correct |
30 | Correct | 65 ms | 13152 KB | Output is correct |
31 | Correct | 83 ms | 14184 KB | Output is correct |
32 | Correct | 82 ms | 14196 KB | Output is correct |
33 | Correct | 80 ms | 14020 KB | Output is correct |
34 | Correct | 83 ms | 14276 KB | Output is correct |
35 | Correct | 80 ms | 13988 KB | Output is correct |
36 | Correct | 84 ms | 14152 KB | Output is correct |
37 | Correct | 93 ms | 14048 KB | Output is correct |
38 | Correct | 87 ms | 13928 KB | Output is correct |
39 | Correct | 89 ms | 14484 KB | Output is correct |
40 | Correct | 84 ms | 14192 KB | Output is correct |
41 | Correct | 61 ms | 13160 KB | Output is correct |
42 | Correct | 67 ms | 13400 KB | Output is correct |
43 | Correct | 76 ms | 13444 KB | Output is correct |
44 | Correct | 63 ms | 13020 KB | Output is correct |
45 | Correct | 75 ms | 13316 KB | Output is correct |
46 | Correct | 63 ms | 13096 KB | Output is correct |
47 | Correct | 64 ms | 13056 KB | Output is correct |
48 | Correct | 67 ms | 13452 KB | Output is correct |
49 | Correct | 62 ms | 12996 KB | Output is correct |
50 | Correct | 72 ms | 13472 KB | Output is correct |
51 | Correct | 99 ms | 14076 KB | Output is correct |
52 | Correct | 104 ms | 13828 KB | Output is correct |
53 | Correct | 99 ms | 14200 KB | Output is correct |
54 | Correct | 97 ms | 13872 KB | Output is correct |
55 | Correct | 99 ms | 14288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8012 KB | Output is correct |
2 | Correct | 4 ms | 5068 KB | Output is correct |
3 | Correct | 4 ms | 6220 KB | Output is correct |
4 | Correct | 5 ms | 8012 KB | Output is correct |
5 | Correct | 3 ms | 4044 KB | Output is correct |
6 | Correct | 7 ms | 8012 KB | Output is correct |
7 | Correct | 3 ms | 4428 KB | Output is correct |
8 | Correct | 6 ms | 8012 KB | Output is correct |
9 | Correct | 3 ms | 3148 KB | Output is correct |
10 | Correct | 6 ms | 8012 KB | Output is correct |
11 | Correct | 5 ms | 8012 KB | Output is correct |
12 | Correct | 7 ms | 8012 KB | Output is correct |
13 | Correct | 5 ms | 8012 KB | Output is correct |
14 | Correct | 5 ms | 7572 KB | Output is correct |
15 | Correct | 7 ms | 8024 KB | Output is correct |
16 | Correct | 6 ms | 8012 KB | Output is correct |
17 | Correct | 5 ms | 8012 KB | Output is correct |
18 | Correct | 7 ms | 8012 KB | Output is correct |
19 | Correct | 6 ms | 8012 KB | Output is correct |
20 | Correct | 6 ms | 8044 KB | Output is correct |
21 | Correct | 6 ms | 8140 KB | Output is correct |
22 | Correct | 7 ms | 8140 KB | Output is correct |
23 | Correct | 6 ms | 8140 KB | Output is correct |
24 | Correct | 6 ms | 8104 KB | Output is correct |
25 | Correct | 6 ms | 8140 KB | Output is correct |
26 | Correct | 83 ms | 13308 KB | Output is correct |
27 | Correct | 80 ms | 13456 KB | Output is correct |
28 | Correct | 66 ms | 13124 KB | Output is correct |
29 | Correct | 62 ms | 12920 KB | Output is correct |
30 | Correct | 65 ms | 13152 KB | Output is correct |
31 | Correct | 83 ms | 14184 KB | Output is correct |
32 | Correct | 82 ms | 14196 KB | Output is correct |
33 | Correct | 80 ms | 14020 KB | Output is correct |
34 | Correct | 83 ms | 14276 KB | Output is correct |
35 | Correct | 80 ms | 13988 KB | Output is correct |
36 | Correct | 84 ms | 14152 KB | Output is correct |
37 | Correct | 93 ms | 14048 KB | Output is correct |
38 | Correct | 87 ms | 13928 KB | Output is correct |
39 | Correct | 89 ms | 14484 KB | Output is correct |
40 | Correct | 84 ms | 14192 KB | Output is correct |
41 | Correct | 61 ms | 13160 KB | Output is correct |
42 | Correct | 67 ms | 13400 KB | Output is correct |
43 | Correct | 76 ms | 13444 KB | Output is correct |
44 | Correct | 63 ms | 13020 KB | Output is correct |
45 | Correct | 75 ms | 13316 KB | Output is correct |
46 | Correct | 63 ms | 13096 KB | Output is correct |
47 | Correct | 64 ms | 13056 KB | Output is correct |
48 | Correct | 67 ms | 13452 KB | Output is correct |
49 | Correct | 62 ms | 12996 KB | Output is correct |
50 | Correct | 72 ms | 13472 KB | Output is correct |
51 | Correct | 99 ms | 14076 KB | Output is correct |
52 | Correct | 104 ms | 13828 KB | Output is correct |
53 | Correct | 99 ms | 14200 KB | Output is correct |
54 | Correct | 97 ms | 13872 KB | Output is correct |
55 | Correct | 99 ms | 14288 KB | Output is correct |
56 | Execution timed out | 1076 ms | 57480 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |