Submission #223604

# Submission time Handle Problem Language Result Execution time Memory
223604 2020-04-15T15:09:20 Z blackbori Pilot (NOI19_pilot) C++14
100 / 100
472 ms 33096 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll D[1010101];
int A[1010101], S[1010101];
int n;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int q, i, j, t;

	cin >> n >> q;

	for(i = 1, j = 0, A[0] = 1e6 + 1; i <= n; i ++){
		cin >> A[i];
		for(; j && A[S[j]] < A[i]; j --){
			D[A[S[j]]] += (ll)(i - S[j]) * (S[j] - S[j - 1]);
		}
		S[++ j] = i;
	}

	for(; j; j --){
		D[A[S[j]]] += (ll)(i - S[j]) * (S[j] - S[j - 1]);
	}

	for(i = 1; i <= 1e6; i ++){
		D[i] += D[i - 1];
	}

	for(; q --; ){
		cin >> t;
		cout << D[t] << "\n";
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 10 ms 8192 KB Output is correct
5 Correct 11 ms 8192 KB Output is correct
6 Correct 11 ms 8168 KB Output is correct
7 Correct 10 ms 8192 KB Output is correct
8 Correct 11 ms 8200 KB Output is correct
9 Correct 10 ms 8192 KB Output is correct
10 Correct 11 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 10 ms 8192 KB Output is correct
5 Correct 11 ms 8192 KB Output is correct
6 Correct 11 ms 8168 KB Output is correct
7 Correct 10 ms 8192 KB Output is correct
8 Correct 11 ms 8200 KB Output is correct
9 Correct 10 ms 8192 KB Output is correct
10 Correct 11 ms 8192 KB Output is correct
11 Correct 10 ms 8088 KB Output is correct
12 Correct 11 ms 8192 KB Output is correct
13 Correct 10 ms 8192 KB Output is correct
14 Correct 11 ms 8192 KB Output is correct
15 Correct 10 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 10 ms 8192 KB Output is correct
5 Correct 11 ms 8192 KB Output is correct
6 Correct 11 ms 8168 KB Output is correct
7 Correct 10 ms 8192 KB Output is correct
8 Correct 11 ms 8200 KB Output is correct
9 Correct 10 ms 8192 KB Output is correct
10 Correct 11 ms 8192 KB Output is correct
11 Correct 10 ms 8088 KB Output is correct
12 Correct 11 ms 8192 KB Output is correct
13 Correct 10 ms 8192 KB Output is correct
14 Correct 11 ms 8192 KB Output is correct
15 Correct 10 ms 8192 KB Output is correct
16 Correct 10 ms 8192 KB Output is correct
17 Correct 11 ms 8192 KB Output is correct
18 Correct 11 ms 8192 KB Output is correct
19 Correct 11 ms 8064 KB Output is correct
20 Correct 11 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 10 ms 8192 KB Output is correct
5 Correct 11 ms 8192 KB Output is correct
6 Correct 11 ms 8168 KB Output is correct
7 Correct 10 ms 8192 KB Output is correct
8 Correct 11 ms 8200 KB Output is correct
9 Correct 10 ms 8192 KB Output is correct
10 Correct 11 ms 8192 KB Output is correct
11 Correct 10 ms 8088 KB Output is correct
12 Correct 11 ms 8192 KB Output is correct
13 Correct 10 ms 8192 KB Output is correct
14 Correct 11 ms 8192 KB Output is correct
15 Correct 10 ms 8192 KB Output is correct
16 Correct 10 ms 8192 KB Output is correct
17 Correct 11 ms 8192 KB Output is correct
18 Correct 11 ms 8192 KB Output is correct
19 Correct 11 ms 8064 KB Output is correct
20 Correct 11 ms 8192 KB Output is correct
21 Correct 11 ms 8192 KB Output is correct
22 Correct 11 ms 8192 KB Output is correct
23 Correct 12 ms 8228 KB Output is correct
24 Correct 11 ms 8192 KB Output is correct
25 Correct 11 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 9088 KB Output is correct
2 Correct 26 ms 9216 KB Output is correct
3 Correct 22 ms 9088 KB Output is correct
4 Correct 25 ms 9208 KB Output is correct
5 Correct 24 ms 9088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 10616 KB Output is correct
2 Correct 47 ms 10616 KB Output is correct
3 Correct 46 ms 10620 KB Output is correct
4 Correct 48 ms 10740 KB Output is correct
5 Correct 44 ms 10620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 10744 KB Output is correct
2 Correct 49 ms 10744 KB Output is correct
3 Correct 56 ms 10744 KB Output is correct
4 Correct 48 ms 10744 KB Output is correct
5 Correct 58 ms 11000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 10 ms 8192 KB Output is correct
5 Correct 11 ms 8192 KB Output is correct
6 Correct 11 ms 8168 KB Output is correct
7 Correct 10 ms 8192 KB Output is correct
8 Correct 11 ms 8200 KB Output is correct
9 Correct 10 ms 8192 KB Output is correct
10 Correct 11 ms 8192 KB Output is correct
11 Correct 22 ms 9088 KB Output is correct
12 Correct 26 ms 9216 KB Output is correct
13 Correct 22 ms 9088 KB Output is correct
14 Correct 25 ms 9208 KB Output is correct
15 Correct 24 ms 9088 KB Output is correct
16 Correct 22 ms 9088 KB Output is correct
17 Correct 32 ms 9216 KB Output is correct
18 Correct 28 ms 9208 KB Output is correct
19 Correct 22 ms 9080 KB Output is correct
20 Correct 26 ms 9216 KB Output is correct
21 Correct 23 ms 9080 KB Output is correct
22 Correct 26 ms 9216 KB Output is correct
23 Correct 23 ms 9216 KB Output is correct
24 Correct 26 ms 9216 KB Output is correct
25 Correct 25 ms 9088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 10 ms 8192 KB Output is correct
5 Correct 11 ms 8192 KB Output is correct
6 Correct 11 ms 8168 KB Output is correct
7 Correct 10 ms 8192 KB Output is correct
8 Correct 11 ms 8200 KB Output is correct
9 Correct 10 ms 8192 KB Output is correct
10 Correct 11 ms 8192 KB Output is correct
11 Correct 10 ms 8088 KB Output is correct
12 Correct 11 ms 8192 KB Output is correct
13 Correct 10 ms 8192 KB Output is correct
14 Correct 11 ms 8192 KB Output is correct
15 Correct 10 ms 8192 KB Output is correct
16 Correct 10 ms 8192 KB Output is correct
17 Correct 11 ms 8192 KB Output is correct
18 Correct 11 ms 8192 KB Output is correct
19 Correct 11 ms 8064 KB Output is correct
20 Correct 11 ms 8192 KB Output is correct
21 Correct 11 ms 8192 KB Output is correct
22 Correct 11 ms 8192 KB Output is correct
23 Correct 12 ms 8228 KB Output is correct
24 Correct 11 ms 8192 KB Output is correct
25 Correct 11 ms 8192 KB Output is correct
26 Correct 22 ms 9088 KB Output is correct
27 Correct 26 ms 9216 KB Output is correct
28 Correct 22 ms 9088 KB Output is correct
29 Correct 25 ms 9208 KB Output is correct
30 Correct 24 ms 9088 KB Output is correct
31 Correct 44 ms 10616 KB Output is correct
32 Correct 47 ms 10616 KB Output is correct
33 Correct 46 ms 10620 KB Output is correct
34 Correct 48 ms 10740 KB Output is correct
35 Correct 44 ms 10620 KB Output is correct
36 Correct 48 ms 10744 KB Output is correct
37 Correct 49 ms 10744 KB Output is correct
38 Correct 56 ms 10744 KB Output is correct
39 Correct 48 ms 10744 KB Output is correct
40 Correct 58 ms 11000 KB Output is correct
41 Correct 22 ms 9088 KB Output is correct
42 Correct 32 ms 9216 KB Output is correct
43 Correct 28 ms 9208 KB Output is correct
44 Correct 22 ms 9080 KB Output is correct
45 Correct 26 ms 9216 KB Output is correct
46 Correct 23 ms 9080 KB Output is correct
47 Correct 26 ms 9216 KB Output is correct
48 Correct 23 ms 9216 KB Output is correct
49 Correct 26 ms 9216 KB Output is correct
50 Correct 25 ms 9088 KB Output is correct
51 Correct 49 ms 10488 KB Output is correct
52 Correct 51 ms 10488 KB Output is correct
53 Correct 47 ms 10488 KB Output is correct
54 Correct 64 ms 10488 KB Output is correct
55 Correct 49 ms 10492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 10 ms 8192 KB Output is correct
5 Correct 11 ms 8192 KB Output is correct
6 Correct 11 ms 8168 KB Output is correct
7 Correct 10 ms 8192 KB Output is correct
8 Correct 11 ms 8200 KB Output is correct
9 Correct 10 ms 8192 KB Output is correct
10 Correct 11 ms 8192 KB Output is correct
11 Correct 10 ms 8088 KB Output is correct
12 Correct 11 ms 8192 KB Output is correct
13 Correct 10 ms 8192 KB Output is correct
14 Correct 11 ms 8192 KB Output is correct
15 Correct 10 ms 8192 KB Output is correct
16 Correct 10 ms 8192 KB Output is correct
17 Correct 11 ms 8192 KB Output is correct
18 Correct 11 ms 8192 KB Output is correct
19 Correct 11 ms 8064 KB Output is correct
20 Correct 11 ms 8192 KB Output is correct
21 Correct 11 ms 8192 KB Output is correct
22 Correct 11 ms 8192 KB Output is correct
23 Correct 12 ms 8228 KB Output is correct
24 Correct 11 ms 8192 KB Output is correct
25 Correct 11 ms 8192 KB Output is correct
26 Correct 22 ms 9088 KB Output is correct
27 Correct 26 ms 9216 KB Output is correct
28 Correct 22 ms 9088 KB Output is correct
29 Correct 25 ms 9208 KB Output is correct
30 Correct 24 ms 9088 KB Output is correct
31 Correct 44 ms 10616 KB Output is correct
32 Correct 47 ms 10616 KB Output is correct
33 Correct 46 ms 10620 KB Output is correct
34 Correct 48 ms 10740 KB Output is correct
35 Correct 44 ms 10620 KB Output is correct
36 Correct 48 ms 10744 KB Output is correct
37 Correct 49 ms 10744 KB Output is correct
38 Correct 56 ms 10744 KB Output is correct
39 Correct 48 ms 10744 KB Output is correct
40 Correct 58 ms 11000 KB Output is correct
41 Correct 22 ms 9088 KB Output is correct
42 Correct 32 ms 9216 KB Output is correct
43 Correct 28 ms 9208 KB Output is correct
44 Correct 22 ms 9080 KB Output is correct
45 Correct 26 ms 9216 KB Output is correct
46 Correct 23 ms 9080 KB Output is correct
47 Correct 26 ms 9216 KB Output is correct
48 Correct 23 ms 9216 KB Output is correct
49 Correct 26 ms 9216 KB Output is correct
50 Correct 25 ms 9088 KB Output is correct
51 Correct 49 ms 10488 KB Output is correct
52 Correct 51 ms 10488 KB Output is correct
53 Correct 47 ms 10488 KB Output is correct
54 Correct 64 ms 10488 KB Output is correct
55 Correct 49 ms 10492 KB Output is correct
56 Correct 452 ms 32376 KB Output is correct
57 Correct 429 ms 31992 KB Output is correct
58 Correct 416 ms 30968 KB Output is correct
59 Correct 442 ms 31332 KB Output is correct
60 Correct 472 ms 33096 KB Output is correct