# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
209790 | 2020-03-15T14:23:44 Z | Alexa2001 | Pilot (NOI19_pilot) | C++17 | 317 ms | 27512 KB |
#include <bits/stdc++.h> using namespace std; /// 16:02 typedef long long ll; const int Nmax = 1e6 + 5; int n, q, h[Nmax], st[Nmax], nxt[Nmax], prv[Nmax]; ll ans[Nmax]; void solve() { int i, nr = 0; for(i=1; i<=n; ++i) { while(nr && h[st[nr]] < h[i]) --nr; prv[i] = st[nr]; st[++nr] = i; } nr = 0; st[0] = n+1; for(i=n; i; --i) { while(nr && h[st[nr]] <= h[i]) --nr; nxt[i] = st[nr]; st[++nr] = i; } for(i=1; i<=n; ++i) ans[h[i]] += (ll) (i - prv[i]) * (nxt[i] - i); } const int bsize = 1 << 18; char buffer[bsize+2]; int cursor; static inline void init_read() { fread(buffer, 1, bsize, stdin), cursor = 0; } template<typename T> void read(T &x) { x = 0; while(!isdigit(buffer[cursor])) { ++cursor; if(cursor == bsize) init_read(); } while(isdigit(buffer[cursor])) { x = x * 10 + buffer[cursor] - '0'; ++cursor; if(cursor == bsize) init_read(); } } int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); cin.tie(0); init_read(); read(n); read(q); int i; for(i=1; i<=n; ++i) read(h[i]); solve(); for(i=1; i<=1000*1000; ++i) ans[i+1] += ans[i]; for(i=1; i<=q; ++i) { int x; read(x); printf("%lld\n", ans[x]); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 10 ms | 8184 KB | Output is correct |
3 | Correct | 10 ms | 8184 KB | Output is correct |
4 | Correct | 10 ms | 8184 KB | Output is correct |
5 | Correct | 11 ms | 8184 KB | Output is correct |
6 | Correct | 10 ms | 8184 KB | Output is correct |
7 | Correct | 11 ms | 8184 KB | Output is correct |
8 | Correct | 11 ms | 8060 KB | Output is correct |
9 | Correct | 11 ms | 8184 KB | Output is correct |
10 | Correct | 13 ms | 8184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 10 ms | 8184 KB | Output is correct |
3 | Correct | 10 ms | 8184 KB | Output is correct |
4 | Correct | 10 ms | 8184 KB | Output is correct |
5 | Correct | 11 ms | 8184 KB | Output is correct |
6 | Correct | 10 ms | 8184 KB | Output is correct |
7 | Correct | 11 ms | 8184 KB | Output is correct |
8 | Correct | 11 ms | 8060 KB | Output is correct |
9 | Correct | 11 ms | 8184 KB | Output is correct |
10 | Correct | 13 ms | 8184 KB | Output is correct |
11 | Correct | 11 ms | 8184 KB | Output is correct |
12 | Correct | 11 ms | 8184 KB | Output is correct |
13 | Correct | 11 ms | 8184 KB | Output is correct |
14 | Correct | 11 ms | 8184 KB | Output is correct |
15 | Correct | 11 ms | 8184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 10 ms | 8184 KB | Output is correct |
3 | Correct | 10 ms | 8184 KB | Output is correct |
4 | Correct | 10 ms | 8184 KB | Output is correct |
5 | Correct | 11 ms | 8184 KB | Output is correct |
6 | Correct | 10 ms | 8184 KB | Output is correct |
7 | Correct | 11 ms | 8184 KB | Output is correct |
8 | Correct | 11 ms | 8060 KB | Output is correct |
9 | Correct | 11 ms | 8184 KB | Output is correct |
10 | Correct | 13 ms | 8184 KB | Output is correct |
11 | Correct | 11 ms | 8184 KB | Output is correct |
12 | Correct | 11 ms | 8184 KB | Output is correct |
13 | Correct | 11 ms | 8184 KB | Output is correct |
14 | Correct | 11 ms | 8184 KB | Output is correct |
15 | Correct | 11 ms | 8184 KB | Output is correct |
16 | Correct | 11 ms | 8184 KB | Output is correct |
17 | Correct | 11 ms | 8184 KB | Output is correct |
18 | Correct | 11 ms | 8184 KB | Output is correct |
19 | Correct | 11 ms | 8184 KB | Output is correct |
20 | Correct | 11 ms | 8184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 10 ms | 8184 KB | Output is correct |
3 | Correct | 10 ms | 8184 KB | Output is correct |
4 | Correct | 10 ms | 8184 KB | Output is correct |
5 | Correct | 11 ms | 8184 KB | Output is correct |
6 | Correct | 10 ms | 8184 KB | Output is correct |
7 | Correct | 11 ms | 8184 KB | Output is correct |
8 | Correct | 11 ms | 8060 KB | Output is correct |
9 | Correct | 11 ms | 8184 KB | Output is correct |
10 | Correct | 13 ms | 8184 KB | Output is correct |
11 | Correct | 11 ms | 8184 KB | Output is correct |
12 | Correct | 11 ms | 8184 KB | Output is correct |
13 | Correct | 11 ms | 8184 KB | Output is correct |
14 | Correct | 11 ms | 8184 KB | Output is correct |
15 | Correct | 11 ms | 8184 KB | Output is correct |
16 | Correct | 11 ms | 8184 KB | Output is correct |
17 | Correct | 11 ms | 8184 KB | Output is correct |
18 | Correct | 11 ms | 8184 KB | Output is correct |
19 | Correct | 11 ms | 8184 KB | Output is correct |
20 | Correct | 11 ms | 8184 KB | Output is correct |
21 | Correct | 11 ms | 8184 KB | Output is correct |
22 | Correct | 10 ms | 8184 KB | Output is correct |
23 | Correct | 11 ms | 8184 KB | Output is correct |
24 | Correct | 10 ms | 8184 KB | Output is correct |
25 | Correct | 11 ms | 8184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 9592 KB | Output is correct |
2 | Correct | 16 ms | 9592 KB | Output is correct |
3 | Correct | 17 ms | 9592 KB | Output is correct |
4 | Correct | 17 ms | 9512 KB | Output is correct |
5 | Correct | 18 ms | 9464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 10872 KB | Output is correct |
2 | Correct | 34 ms | 10876 KB | Output is correct |
3 | Correct | 33 ms | 10872 KB | Output is correct |
4 | Correct | 34 ms | 11000 KB | Output is correct |
5 | Correct | 32 ms | 10872 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 10872 KB | Output is correct |
2 | Correct | 37 ms | 10872 KB | Output is correct |
3 | Correct | 35 ms | 10872 KB | Output is correct |
4 | Correct | 35 ms | 11000 KB | Output is correct |
5 | Correct | 36 ms | 11000 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 10 ms | 8184 KB | Output is correct |
3 | Correct | 10 ms | 8184 KB | Output is correct |
4 | Correct | 10 ms | 8184 KB | Output is correct |
5 | Correct | 11 ms | 8184 KB | Output is correct |
6 | Correct | 10 ms | 8184 KB | Output is correct |
7 | Correct | 11 ms | 8184 KB | Output is correct |
8 | Correct | 11 ms | 8060 KB | Output is correct |
9 | Correct | 11 ms | 8184 KB | Output is correct |
10 | Correct | 13 ms | 8184 KB | Output is correct |
11 | Correct | 16 ms | 9592 KB | Output is correct |
12 | Correct | 16 ms | 9592 KB | Output is correct |
13 | Correct | 17 ms | 9592 KB | Output is correct |
14 | Correct | 17 ms | 9512 KB | Output is correct |
15 | Correct | 18 ms | 9464 KB | Output is correct |
16 | Correct | 16 ms | 9464 KB | Output is correct |
17 | Correct | 16 ms | 9592 KB | Output is correct |
18 | Correct | 16 ms | 9592 KB | Output is correct |
19 | Correct | 16 ms | 9464 KB | Output is correct |
20 | Correct | 16 ms | 9592 KB | Output is correct |
21 | Correct | 16 ms | 9464 KB | Output is correct |
22 | Correct | 17 ms | 9596 KB | Output is correct |
23 | Correct | 17 ms | 9592 KB | Output is correct |
24 | Correct | 15 ms | 9592 KB | Output is correct |
25 | Correct | 16 ms | 9592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 10 ms | 8184 KB | Output is correct |
3 | Correct | 10 ms | 8184 KB | Output is correct |
4 | Correct | 10 ms | 8184 KB | Output is correct |
5 | Correct | 11 ms | 8184 KB | Output is correct |
6 | Correct | 10 ms | 8184 KB | Output is correct |
7 | Correct | 11 ms | 8184 KB | Output is correct |
8 | Correct | 11 ms | 8060 KB | Output is correct |
9 | Correct | 11 ms | 8184 KB | Output is correct |
10 | Correct | 13 ms | 8184 KB | Output is correct |
11 | Correct | 11 ms | 8184 KB | Output is correct |
12 | Correct | 11 ms | 8184 KB | Output is correct |
13 | Correct | 11 ms | 8184 KB | Output is correct |
14 | Correct | 11 ms | 8184 KB | Output is correct |
15 | Correct | 11 ms | 8184 KB | Output is correct |
16 | Correct | 11 ms | 8184 KB | Output is correct |
17 | Correct | 11 ms | 8184 KB | Output is correct |
18 | Correct | 11 ms | 8184 KB | Output is correct |
19 | Correct | 11 ms | 8184 KB | Output is correct |
20 | Correct | 11 ms | 8184 KB | Output is correct |
21 | Correct | 11 ms | 8184 KB | Output is correct |
22 | Correct | 10 ms | 8184 KB | Output is correct |
23 | Correct | 11 ms | 8184 KB | Output is correct |
24 | Correct | 10 ms | 8184 KB | Output is correct |
25 | Correct | 11 ms | 8184 KB | Output is correct |
26 | Correct | 16 ms | 9592 KB | Output is correct |
27 | Correct | 16 ms | 9592 KB | Output is correct |
28 | Correct | 17 ms | 9592 KB | Output is correct |
29 | Correct | 17 ms | 9512 KB | Output is correct |
30 | Correct | 18 ms | 9464 KB | Output is correct |
31 | Correct | 33 ms | 10872 KB | Output is correct |
32 | Correct | 34 ms | 10876 KB | Output is correct |
33 | Correct | 33 ms | 10872 KB | Output is correct |
34 | Correct | 34 ms | 11000 KB | Output is correct |
35 | Correct | 32 ms | 10872 KB | Output is correct |
36 | Correct | 32 ms | 10872 KB | Output is correct |
37 | Correct | 37 ms | 10872 KB | Output is correct |
38 | Correct | 35 ms | 10872 KB | Output is correct |
39 | Correct | 35 ms | 11000 KB | Output is correct |
40 | Correct | 36 ms | 11000 KB | Output is correct |
41 | Correct | 16 ms | 9464 KB | Output is correct |
42 | Correct | 16 ms | 9592 KB | Output is correct |
43 | Correct | 16 ms | 9592 KB | Output is correct |
44 | Correct | 16 ms | 9464 KB | Output is correct |
45 | Correct | 16 ms | 9592 KB | Output is correct |
46 | Correct | 16 ms | 9464 KB | Output is correct |
47 | Correct | 17 ms | 9596 KB | Output is correct |
48 | Correct | 17 ms | 9592 KB | Output is correct |
49 | Correct | 15 ms | 9592 KB | Output is correct |
50 | Correct | 16 ms | 9592 KB | Output is correct |
51 | Correct | 36 ms | 10360 KB | Output is correct |
52 | Correct | 38 ms | 10232 KB | Output is correct |
53 | Correct | 36 ms | 10360 KB | Output is correct |
54 | Correct | 47 ms | 10232 KB | Output is correct |
55 | Correct | 36 ms | 10360 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 10 ms | 8184 KB | Output is correct |
3 | Correct | 10 ms | 8184 KB | Output is correct |
4 | Correct | 10 ms | 8184 KB | Output is correct |
5 | Correct | 11 ms | 8184 KB | Output is correct |
6 | Correct | 10 ms | 8184 KB | Output is correct |
7 | Correct | 11 ms | 8184 KB | Output is correct |
8 | Correct | 11 ms | 8060 KB | Output is correct |
9 | Correct | 11 ms | 8184 KB | Output is correct |
10 | Correct | 13 ms | 8184 KB | Output is correct |
11 | Correct | 11 ms | 8184 KB | Output is correct |
12 | Correct | 11 ms | 8184 KB | Output is correct |
13 | Correct | 11 ms | 8184 KB | Output is correct |
14 | Correct | 11 ms | 8184 KB | Output is correct |
15 | Correct | 11 ms | 8184 KB | Output is correct |
16 | Correct | 11 ms | 8184 KB | Output is correct |
17 | Correct | 11 ms | 8184 KB | Output is correct |
18 | Correct | 11 ms | 8184 KB | Output is correct |
19 | Correct | 11 ms | 8184 KB | Output is correct |
20 | Correct | 11 ms | 8184 KB | Output is correct |
21 | Correct | 11 ms | 8184 KB | Output is correct |
22 | Correct | 10 ms | 8184 KB | Output is correct |
23 | Correct | 11 ms | 8184 KB | Output is correct |
24 | Correct | 10 ms | 8184 KB | Output is correct |
25 | Correct | 11 ms | 8184 KB | Output is correct |
26 | Correct | 16 ms | 9592 KB | Output is correct |
27 | Correct | 16 ms | 9592 KB | Output is correct |
28 | Correct | 17 ms | 9592 KB | Output is correct |
29 | Correct | 17 ms | 9512 KB | Output is correct |
30 | Correct | 18 ms | 9464 KB | Output is correct |
31 | Correct | 33 ms | 10872 KB | Output is correct |
32 | Correct | 34 ms | 10876 KB | Output is correct |
33 | Correct | 33 ms | 10872 KB | Output is correct |
34 | Correct | 34 ms | 11000 KB | Output is correct |
35 | Correct | 32 ms | 10872 KB | Output is correct |
36 | Correct | 32 ms | 10872 KB | Output is correct |
37 | Correct | 37 ms | 10872 KB | Output is correct |
38 | Correct | 35 ms | 10872 KB | Output is correct |
39 | Correct | 35 ms | 11000 KB | Output is correct |
40 | Correct | 36 ms | 11000 KB | Output is correct |
41 | Correct | 16 ms | 9464 KB | Output is correct |
42 | Correct | 16 ms | 9592 KB | Output is correct |
43 | Correct | 16 ms | 9592 KB | Output is correct |
44 | Correct | 16 ms | 9464 KB | Output is correct |
45 | Correct | 16 ms | 9592 KB | Output is correct |
46 | Correct | 16 ms | 9464 KB | Output is correct |
47 | Correct | 17 ms | 9596 KB | Output is correct |
48 | Correct | 17 ms | 9592 KB | Output is correct |
49 | Correct | 15 ms | 9592 KB | Output is correct |
50 | Correct | 16 ms | 9592 KB | Output is correct |
51 | Correct | 36 ms | 10360 KB | Output is correct |
52 | Correct | 38 ms | 10232 KB | Output is correct |
53 | Correct | 36 ms | 10360 KB | Output is correct |
54 | Correct | 47 ms | 10232 KB | Output is correct |
55 | Correct | 36 ms | 10360 KB | Output is correct |
56 | Correct | 304 ms | 27000 KB | Output is correct |
57 | Correct | 290 ms | 27000 KB | Output is correct |
58 | Correct | 293 ms | 26104 KB | Output is correct |
59 | Correct | 278 ms | 26360 KB | Output is correct |
60 | Correct | 317 ms | 27512 KB | Output is correct |