# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
660158 | 2022-11-20T15:03:49 Z | beepbeepsheep | Pilot (NOI19_pilot) | C++17 | 325 ms | 36684 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' typedef pair<ll,ll> ii; const ll inf=1e15; const ll mod=1e9+7; const ll maxn=1e6+5; ll ans[maxn]; ll arr[maxn]; stack<ll> s; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); s.push(0); ll n,q,ele; cin>>n>>q; for (int i=1;i<=n;i++){ cin>>arr[i]; } arr[0]=inf; arr[n+1]=inf; for (int i=1;i<=n+1;i++){ while (arr[s.top()]<arr[i]){ ll a=s.top(); s.pop(); ans[arr[a]]+=(i-s.top()-1)*(i-s.top())/2; if (i==n+1 && s.top()==0) break; ans[min(arr[i],arr[s.top()])]-=(i-s.top()-1)*(i-s.top())/2; } s.push(i); } for (int i=1;i<=maxn;i++){ ans[i]+=ans[i-1]; } for (int i=0;i<q;i++){ cin>>ele; cout<<ans[ele]<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8148 KB | Output is correct |
2 | Correct | 6 ms | 8148 KB | Output is correct |
3 | Correct | 6 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8140 KB | Output is correct |
5 | Correct | 5 ms | 8148 KB | Output is correct |
6 | Correct | 6 ms | 8136 KB | Output is correct |
7 | Correct | 6 ms | 8136 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 5 ms | 8148 KB | Output is correct |
10 | Correct | 6 ms | 8060 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8148 KB | Output is correct |
2 | Correct | 6 ms | 8148 KB | Output is correct |
3 | Correct | 6 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8140 KB | Output is correct |
5 | Correct | 5 ms | 8148 KB | Output is correct |
6 | Correct | 6 ms | 8136 KB | Output is correct |
7 | Correct | 6 ms | 8136 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 5 ms | 8148 KB | Output is correct |
10 | Correct | 6 ms | 8060 KB | Output is correct |
11 | Correct | 5 ms | 8148 KB | Output is correct |
12 | Correct | 5 ms | 8148 KB | Output is correct |
13 | Correct | 6 ms | 8148 KB | Output is correct |
14 | Correct | 6 ms | 8136 KB | Output is correct |
15 | Correct | 5 ms | 8148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8148 KB | Output is correct |
2 | Correct | 6 ms | 8148 KB | Output is correct |
3 | Correct | 6 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8140 KB | Output is correct |
5 | Correct | 5 ms | 8148 KB | Output is correct |
6 | Correct | 6 ms | 8136 KB | Output is correct |
7 | Correct | 6 ms | 8136 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 5 ms | 8148 KB | Output is correct |
10 | Correct | 6 ms | 8060 KB | Output is correct |
11 | Correct | 5 ms | 8148 KB | Output is correct |
12 | Correct | 5 ms | 8148 KB | Output is correct |
13 | Correct | 6 ms | 8148 KB | Output is correct |
14 | Correct | 6 ms | 8136 KB | Output is correct |
15 | Correct | 5 ms | 8148 KB | Output is correct |
16 | Correct | 6 ms | 8148 KB | Output is correct |
17 | Correct | 5 ms | 8128 KB | Output is correct |
18 | Correct | 5 ms | 8064 KB | Output is correct |
19 | Correct | 6 ms | 8148 KB | Output is correct |
20 | Correct | 5 ms | 8148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8148 KB | Output is correct |
2 | Correct | 6 ms | 8148 KB | Output is correct |
3 | Correct | 6 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8140 KB | Output is correct |
5 | Correct | 5 ms | 8148 KB | Output is correct |
6 | Correct | 6 ms | 8136 KB | Output is correct |
7 | Correct | 6 ms | 8136 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 5 ms | 8148 KB | Output is correct |
10 | Correct | 6 ms | 8060 KB | Output is correct |
11 | Correct | 5 ms | 8148 KB | Output is correct |
12 | Correct | 5 ms | 8148 KB | Output is correct |
13 | Correct | 6 ms | 8148 KB | Output is correct |
14 | Correct | 6 ms | 8136 KB | Output is correct |
15 | Correct | 5 ms | 8148 KB | Output is correct |
16 | Correct | 6 ms | 8148 KB | Output is correct |
17 | Correct | 5 ms | 8128 KB | Output is correct |
18 | Correct | 5 ms | 8064 KB | Output is correct |
19 | Correct | 6 ms | 8148 KB | Output is correct |
20 | Correct | 5 ms | 8148 KB | Output is correct |
21 | Correct | 6 ms | 8148 KB | Output is correct |
22 | Correct | 6 ms | 8184 KB | Output is correct |
23 | Correct | 5 ms | 8148 KB | Output is correct |
24 | Correct | 6 ms | 8176 KB | Output is correct |
25 | Correct | 6 ms | 8148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 9428 KB | Output is correct |
2 | Correct | 18 ms | 9544 KB | Output is correct |
3 | Correct | 15 ms | 9412 KB | Output is correct |
4 | Correct | 17 ms | 9424 KB | Output is correct |
5 | Correct | 14 ms | 9424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 10956 KB | Output is correct |
2 | Correct | 31 ms | 10956 KB | Output is correct |
3 | Correct | 38 ms | 10956 KB | Output is correct |
4 | Correct | 34 ms | 11084 KB | Output is correct |
5 | Correct | 33 ms | 10952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 11016 KB | Output is correct |
2 | Correct | 34 ms | 11028 KB | Output is correct |
3 | Correct | 33 ms | 11084 KB | Output is correct |
4 | Correct | 33 ms | 11092 KB | Output is correct |
5 | Correct | 36 ms | 11116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8148 KB | Output is correct |
2 | Correct | 6 ms | 8148 KB | Output is correct |
3 | Correct | 6 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8140 KB | Output is correct |
5 | Correct | 5 ms | 8148 KB | Output is correct |
6 | Correct | 6 ms | 8136 KB | Output is correct |
7 | Correct | 6 ms | 8136 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 5 ms | 8148 KB | Output is correct |
10 | Correct | 6 ms | 8060 KB | Output is correct |
11 | Correct | 20 ms | 9428 KB | Output is correct |
12 | Correct | 18 ms | 9544 KB | Output is correct |
13 | Correct | 15 ms | 9412 KB | Output is correct |
14 | Correct | 17 ms | 9424 KB | Output is correct |
15 | Correct | 14 ms | 9424 KB | Output is correct |
16 | Correct | 14 ms | 9416 KB | Output is correct |
17 | Correct | 16 ms | 9536 KB | Output is correct |
18 | Correct | 19 ms | 9500 KB | Output is correct |
19 | Correct | 15 ms | 9372 KB | Output is correct |
20 | Correct | 16 ms | 9556 KB | Output is correct |
21 | Correct | 15 ms | 9300 KB | Output is correct |
22 | Correct | 15 ms | 9516 KB | Output is correct |
23 | Correct | 14 ms | 9384 KB | Output is correct |
24 | Correct | 17 ms | 9436 KB | Output is correct |
25 | Correct | 15 ms | 9424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8148 KB | Output is correct |
2 | Correct | 6 ms | 8148 KB | Output is correct |
3 | Correct | 6 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8140 KB | Output is correct |
5 | Correct | 5 ms | 8148 KB | Output is correct |
6 | Correct | 6 ms | 8136 KB | Output is correct |
7 | Correct | 6 ms | 8136 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 5 ms | 8148 KB | Output is correct |
10 | Correct | 6 ms | 8060 KB | Output is correct |
11 | Correct | 5 ms | 8148 KB | Output is correct |
12 | Correct | 5 ms | 8148 KB | Output is correct |
13 | Correct | 6 ms | 8148 KB | Output is correct |
14 | Correct | 6 ms | 8136 KB | Output is correct |
15 | Correct | 5 ms | 8148 KB | Output is correct |
16 | Correct | 6 ms | 8148 KB | Output is correct |
17 | Correct | 5 ms | 8128 KB | Output is correct |
18 | Correct | 5 ms | 8064 KB | Output is correct |
19 | Correct | 6 ms | 8148 KB | Output is correct |
20 | Correct | 5 ms | 8148 KB | Output is correct |
21 | Correct | 6 ms | 8148 KB | Output is correct |
22 | Correct | 6 ms | 8184 KB | Output is correct |
23 | Correct | 5 ms | 8148 KB | Output is correct |
24 | Correct | 6 ms | 8176 KB | Output is correct |
25 | Correct | 6 ms | 8148 KB | Output is correct |
26 | Correct | 20 ms | 9428 KB | Output is correct |
27 | Correct | 18 ms | 9544 KB | Output is correct |
28 | Correct | 15 ms | 9412 KB | Output is correct |
29 | Correct | 17 ms | 9424 KB | Output is correct |
30 | Correct | 14 ms | 9424 KB | Output is correct |
31 | Correct | 30 ms | 10956 KB | Output is correct |
32 | Correct | 31 ms | 10956 KB | Output is correct |
33 | Correct | 38 ms | 10956 KB | Output is correct |
34 | Correct | 34 ms | 11084 KB | Output is correct |
35 | Correct | 33 ms | 10952 KB | Output is correct |
36 | Correct | 31 ms | 11016 KB | Output is correct |
37 | Correct | 34 ms | 11028 KB | Output is correct |
38 | Correct | 33 ms | 11084 KB | Output is correct |
39 | Correct | 33 ms | 11092 KB | Output is correct |
40 | Correct | 36 ms | 11116 KB | Output is correct |
41 | Correct | 14 ms | 9416 KB | Output is correct |
42 | Correct | 16 ms | 9536 KB | Output is correct |
43 | Correct | 19 ms | 9500 KB | Output is correct |
44 | Correct | 15 ms | 9372 KB | Output is correct |
45 | Correct | 16 ms | 9556 KB | Output is correct |
46 | Correct | 15 ms | 9300 KB | Output is correct |
47 | Correct | 15 ms | 9516 KB | Output is correct |
48 | Correct | 14 ms | 9384 KB | Output is correct |
49 | Correct | 17 ms | 9436 KB | Output is correct |
50 | Correct | 15 ms | 9424 KB | Output is correct |
51 | Correct | 31 ms | 10828 KB | Output is correct |
52 | Correct | 35 ms | 10700 KB | Output is correct |
53 | Correct | 31 ms | 10780 KB | Output is correct |
54 | Correct | 33 ms | 10664 KB | Output is correct |
55 | Correct | 35 ms | 10828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8148 KB | Output is correct |
2 | Correct | 6 ms | 8148 KB | Output is correct |
3 | Correct | 6 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8140 KB | Output is correct |
5 | Correct | 5 ms | 8148 KB | Output is correct |
6 | Correct | 6 ms | 8136 KB | Output is correct |
7 | Correct | 6 ms | 8136 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 5 ms | 8148 KB | Output is correct |
10 | Correct | 6 ms | 8060 KB | Output is correct |
11 | Correct | 5 ms | 8148 KB | Output is correct |
12 | Correct | 5 ms | 8148 KB | Output is correct |
13 | Correct | 6 ms | 8148 KB | Output is correct |
14 | Correct | 6 ms | 8136 KB | Output is correct |
15 | Correct | 5 ms | 8148 KB | Output is correct |
16 | Correct | 6 ms | 8148 KB | Output is correct |
17 | Correct | 5 ms | 8128 KB | Output is correct |
18 | Correct | 5 ms | 8064 KB | Output is correct |
19 | Correct | 6 ms | 8148 KB | Output is correct |
20 | Correct | 5 ms | 8148 KB | Output is correct |
21 | Correct | 6 ms | 8148 KB | Output is correct |
22 | Correct | 6 ms | 8184 KB | Output is correct |
23 | Correct | 5 ms | 8148 KB | Output is correct |
24 | Correct | 6 ms | 8176 KB | Output is correct |
25 | Correct | 6 ms | 8148 KB | Output is correct |
26 | Correct | 20 ms | 9428 KB | Output is correct |
27 | Correct | 18 ms | 9544 KB | Output is correct |
28 | Correct | 15 ms | 9412 KB | Output is correct |
29 | Correct | 17 ms | 9424 KB | Output is correct |
30 | Correct | 14 ms | 9424 KB | Output is correct |
31 | Correct | 30 ms | 10956 KB | Output is correct |
32 | Correct | 31 ms | 10956 KB | Output is correct |
33 | Correct | 38 ms | 10956 KB | Output is correct |
34 | Correct | 34 ms | 11084 KB | Output is correct |
35 | Correct | 33 ms | 10952 KB | Output is correct |
36 | Correct | 31 ms | 11016 KB | Output is correct |
37 | Correct | 34 ms | 11028 KB | Output is correct |
38 | Correct | 33 ms | 11084 KB | Output is correct |
39 | Correct | 33 ms | 11092 KB | Output is correct |
40 | Correct | 36 ms | 11116 KB | Output is correct |
41 | Correct | 14 ms | 9416 KB | Output is correct |
42 | Correct | 16 ms | 9536 KB | Output is correct |
43 | Correct | 19 ms | 9500 KB | Output is correct |
44 | Correct | 15 ms | 9372 KB | Output is correct |
45 | Correct | 16 ms | 9556 KB | Output is correct |
46 | Correct | 15 ms | 9300 KB | Output is correct |
47 | Correct | 15 ms | 9516 KB | Output is correct |
48 | Correct | 14 ms | 9384 KB | Output is correct |
49 | Correct | 17 ms | 9436 KB | Output is correct |
50 | Correct | 15 ms | 9424 KB | Output is correct |
51 | Correct | 31 ms | 10828 KB | Output is correct |
52 | Correct | 35 ms | 10700 KB | Output is correct |
53 | Correct | 31 ms | 10780 KB | Output is correct |
54 | Correct | 33 ms | 10664 KB | Output is correct |
55 | Correct | 35 ms | 10828 KB | Output is correct |
56 | Correct | 308 ms | 35980 KB | Output is correct |
57 | Correct | 304 ms | 35800 KB | Output is correct |
58 | Correct | 280 ms | 34380 KB | Output is correct |
59 | Correct | 298 ms | 34848 KB | Output is correct |
60 | Correct | 325 ms | 36684 KB | Output is correct |