# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
224224 |
2020-04-17T14:07:27 Z |
bortoz |
Pilot (NOI19_pilot) |
C++17 |
|
1000 ms |
67700 KB |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define fi first
#define se second
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N, Q;
cin >> N >> Q;
vector<pair<int, int>> H(N);
for (int i = 0; i < N; i++) {
cin >> H[i].fi;
H[i].se = i;
}
sort(H.begin(), H.end());
vector<bool> vis(N);
vector<int> par(N), left(N), right(N);
iota(par.begin(), par.end(), 0);
iota(left.begin(), left.end(), 0);
iota(right.begin(), right.end(), 1);
function<ll(int)> way = [&](int v) {
return 1ll * (right[v] - left[v]) * (right[v] - left[v] + 1) / 2;
};
function<int(int)> find = [&](int v) {
return v == par[v] ? v : (par[v] = find(par[v]));
};
function<ll(int, int)> merge = [&](int a, int b) {
a = find(a), b = find(b);
ll r = way(a) + way(b);
par[a] = b;
left[b] = left[a];
return way(b) - r;
};
ll sum = 0;
map<int, ll> res;
for (auto [h, x] : H) {
vis[x] = true;
if (x > 0 && vis[x - 1]) {
sum += merge(x - 1, x);
}
if (x + 1 < N && vis[x + 1]) {
sum += merge(x, x + 1);
}
res[h] = sum += 1;
}
for (int i = 0; i < Q; i++) {
int Y;
cin >> Y;
auto it = res.upper_bound(Y);
cout << (it == res.begin() ? 0ll : prev(it)->se) << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
6 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
512 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
6648 KB |
Output is correct |
2 |
Correct |
55 ms |
8824 KB |
Output is correct |
3 |
Correct |
47 ms |
6520 KB |
Output is correct |
4 |
Correct |
50 ms |
8184 KB |
Output is correct |
5 |
Correct |
48 ms |
6392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
10104 KB |
Output is correct |
2 |
Correct |
93 ms |
10104 KB |
Output is correct |
3 |
Correct |
99 ms |
9976 KB |
Output is correct |
4 |
Correct |
95 ms |
10360 KB |
Output is correct |
5 |
Correct |
90 ms |
9976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
10232 KB |
Output is correct |
2 |
Correct |
127 ms |
10488 KB |
Output is correct |
3 |
Correct |
118 ms |
10104 KB |
Output is correct |
4 |
Correct |
111 ms |
10744 KB |
Output is correct |
5 |
Correct |
112 ms |
10360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
50 ms |
6648 KB |
Output is correct |
12 |
Correct |
55 ms |
8824 KB |
Output is correct |
13 |
Correct |
47 ms |
6520 KB |
Output is correct |
14 |
Correct |
50 ms |
8184 KB |
Output is correct |
15 |
Correct |
48 ms |
6392 KB |
Output is correct |
16 |
Correct |
54 ms |
6392 KB |
Output is correct |
17 |
Correct |
53 ms |
8824 KB |
Output is correct |
18 |
Correct |
57 ms |
8824 KB |
Output is correct |
19 |
Correct |
45 ms |
6392 KB |
Output is correct |
20 |
Correct |
52 ms |
8696 KB |
Output is correct |
21 |
Correct |
47 ms |
6272 KB |
Output is correct |
22 |
Correct |
54 ms |
8312 KB |
Output is correct |
23 |
Correct |
52 ms |
6776 KB |
Output is correct |
24 |
Correct |
54 ms |
8184 KB |
Output is correct |
25 |
Correct |
50 ms |
6648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
6 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
512 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
50 ms |
6648 KB |
Output is correct |
27 |
Correct |
55 ms |
8824 KB |
Output is correct |
28 |
Correct |
47 ms |
6520 KB |
Output is correct |
29 |
Correct |
50 ms |
8184 KB |
Output is correct |
30 |
Correct |
48 ms |
6392 KB |
Output is correct |
31 |
Correct |
95 ms |
10104 KB |
Output is correct |
32 |
Correct |
93 ms |
10104 KB |
Output is correct |
33 |
Correct |
99 ms |
9976 KB |
Output is correct |
34 |
Correct |
95 ms |
10360 KB |
Output is correct |
35 |
Correct |
90 ms |
9976 KB |
Output is correct |
36 |
Correct |
126 ms |
10232 KB |
Output is correct |
37 |
Correct |
127 ms |
10488 KB |
Output is correct |
38 |
Correct |
118 ms |
10104 KB |
Output is correct |
39 |
Correct |
111 ms |
10744 KB |
Output is correct |
40 |
Correct |
112 ms |
10360 KB |
Output is correct |
41 |
Correct |
54 ms |
6392 KB |
Output is correct |
42 |
Correct |
53 ms |
8824 KB |
Output is correct |
43 |
Correct |
57 ms |
8824 KB |
Output is correct |
44 |
Correct |
45 ms |
6392 KB |
Output is correct |
45 |
Correct |
52 ms |
8696 KB |
Output is correct |
46 |
Correct |
47 ms |
6272 KB |
Output is correct |
47 |
Correct |
54 ms |
8312 KB |
Output is correct |
48 |
Correct |
52 ms |
6776 KB |
Output is correct |
49 |
Correct |
54 ms |
8184 KB |
Output is correct |
50 |
Correct |
50 ms |
6648 KB |
Output is correct |
51 |
Correct |
99 ms |
8056 KB |
Output is correct |
52 |
Correct |
127 ms |
9720 KB |
Output is correct |
53 |
Correct |
96 ms |
8056 KB |
Output is correct |
54 |
Correct |
126 ms |
9724 KB |
Output is correct |
55 |
Correct |
98 ms |
8184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
6 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
512 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
50 ms |
6648 KB |
Output is correct |
27 |
Correct |
55 ms |
8824 KB |
Output is correct |
28 |
Correct |
47 ms |
6520 KB |
Output is correct |
29 |
Correct |
50 ms |
8184 KB |
Output is correct |
30 |
Correct |
48 ms |
6392 KB |
Output is correct |
31 |
Correct |
95 ms |
10104 KB |
Output is correct |
32 |
Correct |
93 ms |
10104 KB |
Output is correct |
33 |
Correct |
99 ms |
9976 KB |
Output is correct |
34 |
Correct |
95 ms |
10360 KB |
Output is correct |
35 |
Correct |
90 ms |
9976 KB |
Output is correct |
36 |
Correct |
126 ms |
10232 KB |
Output is correct |
37 |
Correct |
127 ms |
10488 KB |
Output is correct |
38 |
Correct |
118 ms |
10104 KB |
Output is correct |
39 |
Correct |
111 ms |
10744 KB |
Output is correct |
40 |
Correct |
112 ms |
10360 KB |
Output is correct |
41 |
Correct |
54 ms |
6392 KB |
Output is correct |
42 |
Correct |
53 ms |
8824 KB |
Output is correct |
43 |
Correct |
57 ms |
8824 KB |
Output is correct |
44 |
Correct |
45 ms |
6392 KB |
Output is correct |
45 |
Correct |
52 ms |
8696 KB |
Output is correct |
46 |
Correct |
47 ms |
6272 KB |
Output is correct |
47 |
Correct |
54 ms |
8312 KB |
Output is correct |
48 |
Correct |
52 ms |
6776 KB |
Output is correct |
49 |
Correct |
54 ms |
8184 KB |
Output is correct |
50 |
Correct |
50 ms |
6648 KB |
Output is correct |
51 |
Correct |
99 ms |
8056 KB |
Output is correct |
52 |
Correct |
127 ms |
9720 KB |
Output is correct |
53 |
Correct |
96 ms |
8056 KB |
Output is correct |
54 |
Correct |
126 ms |
9724 KB |
Output is correct |
55 |
Correct |
98 ms |
8184 KB |
Output is correct |
56 |
Execution timed out |
1091 ms |
67700 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |