# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083486 | 2024-09-03T10:01:34 Z | lamlamlam | Pilot (NOI19_pilot) | C++17 | 334 ms | 68076 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' const int MN = 1e6+5; int n,q,h[MN],y,ans[MN],pa[MN],sz[MN],res; vector<pair<int,int>> v; int papa(int x) { if(x==pa[x]) return x; return pa[x] = papa(pa[x]); } void uni_set(int u,int v) { int p1 = papa(u); int p2 = papa(v); if(p1==p2) return; //cout << "LOL\n"; if(sz[p1]<sz[p2]) swap(p1,p2); res += sz[p1]*sz[p2]; sz[p1] += sz[p2]; pa[p2] = p1; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #define task "sus" if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } for(int i=0; i<MN; i++) pa[i] = i, sz[i] = 1; cin >> n >> q; for(int i=1; i<=n; i++) cin >> h[i],v.push_back({h[i],i}); sort(v.begin(),v.end()); int it = 0; for(int i=1; i<MN; i++){ while(it<n and v[it].first==i){ int val = v[it].first; int id = v[it].second; res++; if(id!=1 and val>=h[id-1]) uni_set(id,id-1); if(id!=n and val>=h[id+1]) uni_set(id,id+1); it++; } ans[i] = res; } while(q--){ cin >> y; cout << ans[y] << endl; } cerr << "\nTime: " << clock(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 23900 KB | Output is correct |
2 | Correct | 10 ms | 24072 KB | Output is correct |
3 | Correct | 10 ms | 23900 KB | Output is correct |
4 | Correct | 10 ms | 23708 KB | Output is correct |
5 | Correct | 10 ms | 23900 KB | Output is correct |
6 | Correct | 9 ms | 23800 KB | Output is correct |
7 | Correct | 10 ms | 23900 KB | Output is correct |
8 | Correct | 9 ms | 23892 KB | Output is correct |
9 | Correct | 11 ms | 23900 KB | Output is correct |
10 | Correct | 10 ms | 23900 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 23900 KB | Output is correct |
2 | Correct | 10 ms | 24072 KB | Output is correct |
3 | Correct | 10 ms | 23900 KB | Output is correct |
4 | Correct | 10 ms | 23708 KB | Output is correct |
5 | Correct | 10 ms | 23900 KB | Output is correct |
6 | Correct | 9 ms | 23800 KB | Output is correct |
7 | Correct | 10 ms | 23900 KB | Output is correct |
8 | Correct | 9 ms | 23892 KB | Output is correct |
9 | Correct | 11 ms | 23900 KB | Output is correct |
10 | Correct | 10 ms | 23900 KB | Output is correct |
11 | Correct | 10 ms | 23900 KB | Output is correct |
12 | Correct | 9 ms | 23900 KB | Output is correct |
13 | Correct | 10 ms | 23804 KB | Output is correct |
14 | Correct | 9 ms | 23896 KB | Output is correct |
15 | Correct | 10 ms | 23768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 23900 KB | Output is correct |
2 | Correct | 10 ms | 24072 KB | Output is correct |
3 | Correct | 10 ms | 23900 KB | Output is correct |
4 | Correct | 10 ms | 23708 KB | Output is correct |
5 | Correct | 10 ms | 23900 KB | Output is correct |
6 | Correct | 9 ms | 23800 KB | Output is correct |
7 | Correct | 10 ms | 23900 KB | Output is correct |
8 | Correct | 9 ms | 23892 KB | Output is correct |
9 | Correct | 11 ms | 23900 KB | Output is correct |
10 | Correct | 10 ms | 23900 KB | Output is correct |
11 | Correct | 10 ms | 23900 KB | Output is correct |
12 | Correct | 9 ms | 23900 KB | Output is correct |
13 | Correct | 10 ms | 23804 KB | Output is correct |
14 | Correct | 9 ms | 23896 KB | Output is correct |
15 | Correct | 10 ms | 23768 KB | Output is correct |
16 | Correct | 10 ms | 23900 KB | Output is correct |
17 | Correct | 10 ms | 23900 KB | Output is correct |
18 | Correct | 9 ms | 23900 KB | Output is correct |
19 | Correct | 9 ms | 23944 KB | Output is correct |
20 | Correct | 9 ms | 23900 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 23900 KB | Output is correct |
2 | Correct | 10 ms | 24072 KB | Output is correct |
3 | Correct | 10 ms | 23900 KB | Output is correct |
4 | Correct | 10 ms | 23708 KB | Output is correct |
5 | Correct | 10 ms | 23900 KB | Output is correct |
6 | Correct | 9 ms | 23800 KB | Output is correct |
7 | Correct | 10 ms | 23900 KB | Output is correct |
8 | Correct | 9 ms | 23892 KB | Output is correct |
9 | Correct | 11 ms | 23900 KB | Output is correct |
10 | Correct | 10 ms | 23900 KB | Output is correct |
11 | Correct | 10 ms | 23900 KB | Output is correct |
12 | Correct | 9 ms | 23900 KB | Output is correct |
13 | Correct | 10 ms | 23804 KB | Output is correct |
14 | Correct | 9 ms | 23896 KB | Output is correct |
15 | Correct | 10 ms | 23768 KB | Output is correct |
16 | Correct | 10 ms | 23900 KB | Output is correct |
17 | Correct | 10 ms | 23900 KB | Output is correct |
18 | Correct | 9 ms | 23900 KB | Output is correct |
19 | Correct | 9 ms | 23944 KB | Output is correct |
20 | Correct | 9 ms | 23900 KB | Output is correct |
21 | Correct | 10 ms | 23896 KB | Output is correct |
22 | Correct | 10 ms | 23900 KB | Output is correct |
23 | Correct | 12 ms | 23900 KB | Output is correct |
24 | Correct | 13 ms | 23912 KB | Output is correct |
25 | Correct | 10 ms | 23896 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 26828 KB | Output is correct |
2 | Correct | 30 ms | 26828 KB | Output is correct |
3 | Correct | 28 ms | 26828 KB | Output is correct |
4 | Correct | 33 ms | 26744 KB | Output is correct |
5 | Correct | 29 ms | 26576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 28152 KB | Output is correct |
2 | Correct | 32 ms | 28360 KB | Output is correct |
3 | Correct | 29 ms | 28328 KB | Output is correct |
4 | Correct | 29 ms | 28372 KB | Output is correct |
5 | Correct | 31 ms | 28104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 28368 KB | Output is correct |
2 | Correct | 35 ms | 28452 KB | Output is correct |
3 | Correct | 34 ms | 28452 KB | Output is correct |
4 | Correct | 36 ms | 28616 KB | Output is correct |
5 | Correct | 33 ms | 28616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 23900 KB | Output is correct |
2 | Correct | 10 ms | 24072 KB | Output is correct |
3 | Correct | 10 ms | 23900 KB | Output is correct |
4 | Correct | 10 ms | 23708 KB | Output is correct |
5 | Correct | 10 ms | 23900 KB | Output is correct |
6 | Correct | 9 ms | 23800 KB | Output is correct |
7 | Correct | 10 ms | 23900 KB | Output is correct |
8 | Correct | 9 ms | 23892 KB | Output is correct |
9 | Correct | 11 ms | 23900 KB | Output is correct |
10 | Correct | 10 ms | 23900 KB | Output is correct |
11 | Correct | 35 ms | 26828 KB | Output is correct |
12 | Correct | 30 ms | 26828 KB | Output is correct |
13 | Correct | 28 ms | 26828 KB | Output is correct |
14 | Correct | 33 ms | 26744 KB | Output is correct |
15 | Correct | 29 ms | 26576 KB | Output is correct |
16 | Correct | 27 ms | 26580 KB | Output is correct |
17 | Correct | 27 ms | 26832 KB | Output is correct |
18 | Correct | 31 ms | 26952 KB | Output is correct |
19 | Correct | 28 ms | 26652 KB | Output is correct |
20 | Correct | 28 ms | 26852 KB | Output is correct |
21 | Correct | 26 ms | 26568 KB | Output is correct |
22 | Correct | 27 ms | 26824 KB | Output is correct |
23 | Correct | 26 ms | 26912 KB | Output is correct |
24 | Correct | 28 ms | 26824 KB | Output is correct |
25 | Correct | 27 ms | 26772 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 23900 KB | Output is correct |
2 | Correct | 10 ms | 24072 KB | Output is correct |
3 | Correct | 10 ms | 23900 KB | Output is correct |
4 | Correct | 10 ms | 23708 KB | Output is correct |
5 | Correct | 10 ms | 23900 KB | Output is correct |
6 | Correct | 9 ms | 23800 KB | Output is correct |
7 | Correct | 10 ms | 23900 KB | Output is correct |
8 | Correct | 9 ms | 23892 KB | Output is correct |
9 | Correct | 11 ms | 23900 KB | Output is correct |
10 | Correct | 10 ms | 23900 KB | Output is correct |
11 | Correct | 10 ms | 23900 KB | Output is correct |
12 | Correct | 9 ms | 23900 KB | Output is correct |
13 | Correct | 10 ms | 23804 KB | Output is correct |
14 | Correct | 9 ms | 23896 KB | Output is correct |
15 | Correct | 10 ms | 23768 KB | Output is correct |
16 | Correct | 10 ms | 23900 KB | Output is correct |
17 | Correct | 10 ms | 23900 KB | Output is correct |
18 | Correct | 9 ms | 23900 KB | Output is correct |
19 | Correct | 9 ms | 23944 KB | Output is correct |
20 | Correct | 9 ms | 23900 KB | Output is correct |
21 | Correct | 10 ms | 23896 KB | Output is correct |
22 | Correct | 10 ms | 23900 KB | Output is correct |
23 | Correct | 12 ms | 23900 KB | Output is correct |
24 | Correct | 13 ms | 23912 KB | Output is correct |
25 | Correct | 10 ms | 23896 KB | Output is correct |
26 | Correct | 35 ms | 26828 KB | Output is correct |
27 | Correct | 30 ms | 26828 KB | Output is correct |
28 | Correct | 28 ms | 26828 KB | Output is correct |
29 | Correct | 33 ms | 26744 KB | Output is correct |
30 | Correct | 29 ms | 26576 KB | Output is correct |
31 | Correct | 35 ms | 28152 KB | Output is correct |
32 | Correct | 32 ms | 28360 KB | Output is correct |
33 | Correct | 29 ms | 28328 KB | Output is correct |
34 | Correct | 29 ms | 28372 KB | Output is correct |
35 | Correct | 31 ms | 28104 KB | Output is correct |
36 | Correct | 32 ms | 28368 KB | Output is correct |
37 | Correct | 35 ms | 28452 KB | Output is correct |
38 | Correct | 34 ms | 28452 KB | Output is correct |
39 | Correct | 36 ms | 28616 KB | Output is correct |
40 | Correct | 33 ms | 28616 KB | Output is correct |
41 | Correct | 27 ms | 26580 KB | Output is correct |
42 | Correct | 27 ms | 26832 KB | Output is correct |
43 | Correct | 31 ms | 26952 KB | Output is correct |
44 | Correct | 28 ms | 26652 KB | Output is correct |
45 | Correct | 28 ms | 26852 KB | Output is correct |
46 | Correct | 26 ms | 26568 KB | Output is correct |
47 | Correct | 27 ms | 26824 KB | Output is correct |
48 | Correct | 26 ms | 26912 KB | Output is correct |
49 | Correct | 28 ms | 26824 KB | Output is correct |
50 | Correct | 27 ms | 26772 KB | Output is correct |
51 | Correct | 45 ms | 28104 KB | Output is correct |
52 | Correct | 44 ms | 28064 KB | Output is correct |
53 | Correct | 38 ms | 28104 KB | Output is correct |
54 | Correct | 46 ms | 28064 KB | Output is correct |
55 | Correct | 39 ms | 28100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 23900 KB | Output is correct |
2 | Correct | 10 ms | 24072 KB | Output is correct |
3 | Correct | 10 ms | 23900 KB | Output is correct |
4 | Correct | 10 ms | 23708 KB | Output is correct |
5 | Correct | 10 ms | 23900 KB | Output is correct |
6 | Correct | 9 ms | 23800 KB | Output is correct |
7 | Correct | 10 ms | 23900 KB | Output is correct |
8 | Correct | 9 ms | 23892 KB | Output is correct |
9 | Correct | 11 ms | 23900 KB | Output is correct |
10 | Correct | 10 ms | 23900 KB | Output is correct |
11 | Correct | 10 ms | 23900 KB | Output is correct |
12 | Correct | 9 ms | 23900 KB | Output is correct |
13 | Correct | 10 ms | 23804 KB | Output is correct |
14 | Correct | 9 ms | 23896 KB | Output is correct |
15 | Correct | 10 ms | 23768 KB | Output is correct |
16 | Correct | 10 ms | 23900 KB | Output is correct |
17 | Correct | 10 ms | 23900 KB | Output is correct |
18 | Correct | 9 ms | 23900 KB | Output is correct |
19 | Correct | 9 ms | 23944 KB | Output is correct |
20 | Correct | 9 ms | 23900 KB | Output is correct |
21 | Correct | 10 ms | 23896 KB | Output is correct |
22 | Correct | 10 ms | 23900 KB | Output is correct |
23 | Correct | 12 ms | 23900 KB | Output is correct |
24 | Correct | 13 ms | 23912 KB | Output is correct |
25 | Correct | 10 ms | 23896 KB | Output is correct |
26 | Correct | 35 ms | 26828 KB | Output is correct |
27 | Correct | 30 ms | 26828 KB | Output is correct |
28 | Correct | 28 ms | 26828 KB | Output is correct |
29 | Correct | 33 ms | 26744 KB | Output is correct |
30 | Correct | 29 ms | 26576 KB | Output is correct |
31 | Correct | 35 ms | 28152 KB | Output is correct |
32 | Correct | 32 ms | 28360 KB | Output is correct |
33 | Correct | 29 ms | 28328 KB | Output is correct |
34 | Correct | 29 ms | 28372 KB | Output is correct |
35 | Correct | 31 ms | 28104 KB | Output is correct |
36 | Correct | 32 ms | 28368 KB | Output is correct |
37 | Correct | 35 ms | 28452 KB | Output is correct |
38 | Correct | 34 ms | 28452 KB | Output is correct |
39 | Correct | 36 ms | 28616 KB | Output is correct |
40 | Correct | 33 ms | 28616 KB | Output is correct |
41 | Correct | 27 ms | 26580 KB | Output is correct |
42 | Correct | 27 ms | 26832 KB | Output is correct |
43 | Correct | 31 ms | 26952 KB | Output is correct |
44 | Correct | 28 ms | 26652 KB | Output is correct |
45 | Correct | 28 ms | 26852 KB | Output is correct |
46 | Correct | 26 ms | 26568 KB | Output is correct |
47 | Correct | 27 ms | 26824 KB | Output is correct |
48 | Correct | 26 ms | 26912 KB | Output is correct |
49 | Correct | 28 ms | 26824 KB | Output is correct |
50 | Correct | 27 ms | 26772 KB | Output is correct |
51 | Correct | 45 ms | 28104 KB | Output is correct |
52 | Correct | 44 ms | 28064 KB | Output is correct |
53 | Correct | 38 ms | 28104 KB | Output is correct |
54 | Correct | 46 ms | 28064 KB | Output is correct |
55 | Correct | 39 ms | 28100 KB | Output is correct |
56 | Correct | 334 ms | 66464 KB | Output is correct |
57 | Correct | 324 ms | 67356 KB | Output is correct |
58 | Correct | 309 ms | 64364 KB | Output is correct |
59 | Correct | 330 ms | 65408 KB | Output is correct |
60 | Correct | 333 ms | 68076 KB | Output is correct |