# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
966952 |
2024-04-20T17:28:10 Z |
stefanneagu |
Pilot (NOI19_pilot) |
C++17 |
|
44 ms |
14676 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int nmax = 1e5 + 1;
struct str {
int aa, i;
} a[nmax], ord[nmax];
int v[nmax], ans[nmax], sz[nmax], root[nmax];
bool f[nmax];
int cmp(str x, str y) {
return x.aa < y.aa;
}
int find(int a) {
if(root[a] == a) {
return a;
}
return root[a] = find(root[a]);
}
int curr = 0;
void unite(int a, int b) {
if(a == b) {
cout << a << " " << b << '\n';
exit(0);
// assert(0); // nu cred ca ar tb sa aj aici
}
if(sz[a] < sz[b]) {
swap(a, b);
}
curr += sz[a] * sz[b];
// cout << "+ " << sz[a] << " " << sz[b] << '\n';
root[b] = a;
sz[a] += sz[b];
}
void upd(int a) {
f[a] = 1;
curr++;
if(f[a - 1] == 1) {
// cout << "? " << a << " " << a - 1 << '\n';
unite(find(a), find(a - 1));
}
if(f[a + 1] == 1) {
// cout << "! " << a << " " << a + 1 << '\n';
unite(find(a), find(a + 1));
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie();
cout.tie();
int n, q;
cin >> n >> q;
for(int i = 1; i <= n; i++) {
sz[i] = 1, root[i] = i;
cin >> v[i];
ord[i].aa = v[i];
ord[i].i = i;
}
sort(ord + 1, ord + n + 1, cmp);
for(int i = 1; i <= q; i++) {
cin >> a[i].aa;
a[i].i = i;
}
sort(a + 1, a + q + 1, cmp);
int j = 1;
for(int i = 1; i <= q; i++) { // rainboy orz
while(j <= n && ord[j].aa <= a[i].aa) {
// cout << "~ " << ord[j].i << "\n";
upd(ord[j].i);
j++;
}
ans[a[i].i] = curr;
// cout << '\n';
}
for(int i = 1; i <= q; i++) {
cout << ans[i] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
1 ms |
6740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
1 ms |
6740 KB |
Output is correct |
11 |
Correct |
1 ms |
6488 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6612 KB |
Output is correct |
15 |
Correct |
1 ms |
6496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
1 ms |
6740 KB |
Output is correct |
11 |
Correct |
1 ms |
6488 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6612 KB |
Output is correct |
15 |
Correct |
1 ms |
6496 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
1 ms |
6740 KB |
Output is correct |
11 |
Correct |
1 ms |
6488 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6612 KB |
Output is correct |
15 |
Correct |
1 ms |
6496 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
1 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6656 KB |
Output is correct |
23 |
Correct |
1 ms |
6492 KB |
Output is correct |
24 |
Correct |
1 ms |
6492 KB |
Output is correct |
25 |
Correct |
1 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
7256 KB |
Output is correct |
2 |
Correct |
18 ms |
7364 KB |
Output is correct |
3 |
Correct |
17 ms |
7316 KB |
Output is correct |
4 |
Correct |
17 ms |
7260 KB |
Output is correct |
5 |
Correct |
17 ms |
7260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
8496 KB |
Output is correct |
2 |
Correct |
33 ms |
8844 KB |
Output is correct |
3 |
Correct |
37 ms |
8784 KB |
Output is correct |
4 |
Correct |
33 ms |
8908 KB |
Output is correct |
5 |
Correct |
32 ms |
8784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
8276 KB |
Output is correct |
2 |
Correct |
33 ms |
8784 KB |
Output is correct |
3 |
Correct |
34 ms |
8788 KB |
Output is correct |
4 |
Correct |
36 ms |
8788 KB |
Output is correct |
5 |
Correct |
44 ms |
9036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
1 ms |
6740 KB |
Output is correct |
11 |
Correct |
17 ms |
7256 KB |
Output is correct |
12 |
Correct |
18 ms |
7364 KB |
Output is correct |
13 |
Correct |
17 ms |
7316 KB |
Output is correct |
14 |
Correct |
17 ms |
7260 KB |
Output is correct |
15 |
Correct |
17 ms |
7260 KB |
Output is correct |
16 |
Correct |
16 ms |
7512 KB |
Output is correct |
17 |
Correct |
16 ms |
7356 KB |
Output is correct |
18 |
Correct |
16 ms |
7372 KB |
Output is correct |
19 |
Correct |
15 ms |
7260 KB |
Output is correct |
20 |
Correct |
17 ms |
7260 KB |
Output is correct |
21 |
Correct |
18 ms |
7228 KB |
Output is correct |
22 |
Correct |
15 ms |
7332 KB |
Output is correct |
23 |
Correct |
20 ms |
7260 KB |
Output is correct |
24 |
Correct |
15 ms |
7260 KB |
Output is correct |
25 |
Correct |
16 ms |
7260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
1 ms |
6740 KB |
Output is correct |
11 |
Correct |
1 ms |
6488 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6612 KB |
Output is correct |
15 |
Correct |
1 ms |
6496 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
1 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6656 KB |
Output is correct |
23 |
Correct |
1 ms |
6492 KB |
Output is correct |
24 |
Correct |
1 ms |
6492 KB |
Output is correct |
25 |
Correct |
1 ms |
6492 KB |
Output is correct |
26 |
Correct |
17 ms |
7256 KB |
Output is correct |
27 |
Correct |
18 ms |
7364 KB |
Output is correct |
28 |
Correct |
17 ms |
7316 KB |
Output is correct |
29 |
Correct |
17 ms |
7260 KB |
Output is correct |
30 |
Correct |
17 ms |
7260 KB |
Output is correct |
31 |
Correct |
32 ms |
8496 KB |
Output is correct |
32 |
Correct |
33 ms |
8844 KB |
Output is correct |
33 |
Correct |
37 ms |
8784 KB |
Output is correct |
34 |
Correct |
33 ms |
8908 KB |
Output is correct |
35 |
Correct |
32 ms |
8784 KB |
Output is correct |
36 |
Correct |
33 ms |
8276 KB |
Output is correct |
37 |
Correct |
33 ms |
8784 KB |
Output is correct |
38 |
Correct |
34 ms |
8788 KB |
Output is correct |
39 |
Correct |
36 ms |
8788 KB |
Output is correct |
40 |
Correct |
44 ms |
9036 KB |
Output is correct |
41 |
Correct |
16 ms |
7512 KB |
Output is correct |
42 |
Correct |
16 ms |
7356 KB |
Output is correct |
43 |
Correct |
16 ms |
7372 KB |
Output is correct |
44 |
Correct |
15 ms |
7260 KB |
Output is correct |
45 |
Correct |
17 ms |
7260 KB |
Output is correct |
46 |
Correct |
18 ms |
7228 KB |
Output is correct |
47 |
Correct |
15 ms |
7332 KB |
Output is correct |
48 |
Correct |
20 ms |
7260 KB |
Output is correct |
49 |
Correct |
15 ms |
7260 KB |
Output is correct |
50 |
Correct |
16 ms |
7260 KB |
Output is correct |
51 |
Correct |
39 ms |
8716 KB |
Output is correct |
52 |
Correct |
39 ms |
8484 KB |
Output is correct |
53 |
Correct |
42 ms |
8520 KB |
Output is correct |
54 |
Correct |
39 ms |
8488 KB |
Output is correct |
55 |
Correct |
38 ms |
8624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
1 ms |
6740 KB |
Output is correct |
11 |
Correct |
1 ms |
6488 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6612 KB |
Output is correct |
15 |
Correct |
1 ms |
6496 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
1 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6656 KB |
Output is correct |
23 |
Correct |
1 ms |
6492 KB |
Output is correct |
24 |
Correct |
1 ms |
6492 KB |
Output is correct |
25 |
Correct |
1 ms |
6492 KB |
Output is correct |
26 |
Correct |
17 ms |
7256 KB |
Output is correct |
27 |
Correct |
18 ms |
7364 KB |
Output is correct |
28 |
Correct |
17 ms |
7316 KB |
Output is correct |
29 |
Correct |
17 ms |
7260 KB |
Output is correct |
30 |
Correct |
17 ms |
7260 KB |
Output is correct |
31 |
Correct |
32 ms |
8496 KB |
Output is correct |
32 |
Correct |
33 ms |
8844 KB |
Output is correct |
33 |
Correct |
37 ms |
8784 KB |
Output is correct |
34 |
Correct |
33 ms |
8908 KB |
Output is correct |
35 |
Correct |
32 ms |
8784 KB |
Output is correct |
36 |
Correct |
33 ms |
8276 KB |
Output is correct |
37 |
Correct |
33 ms |
8784 KB |
Output is correct |
38 |
Correct |
34 ms |
8788 KB |
Output is correct |
39 |
Correct |
36 ms |
8788 KB |
Output is correct |
40 |
Correct |
44 ms |
9036 KB |
Output is correct |
41 |
Correct |
16 ms |
7512 KB |
Output is correct |
42 |
Correct |
16 ms |
7356 KB |
Output is correct |
43 |
Correct |
16 ms |
7372 KB |
Output is correct |
44 |
Correct |
15 ms |
7260 KB |
Output is correct |
45 |
Correct |
17 ms |
7260 KB |
Output is correct |
46 |
Correct |
18 ms |
7228 KB |
Output is correct |
47 |
Correct |
15 ms |
7332 KB |
Output is correct |
48 |
Correct |
20 ms |
7260 KB |
Output is correct |
49 |
Correct |
15 ms |
7260 KB |
Output is correct |
50 |
Correct |
16 ms |
7260 KB |
Output is correct |
51 |
Correct |
39 ms |
8716 KB |
Output is correct |
52 |
Correct |
39 ms |
8484 KB |
Output is correct |
53 |
Correct |
42 ms |
8520 KB |
Output is correct |
54 |
Correct |
39 ms |
8488 KB |
Output is correct |
55 |
Correct |
38 ms |
8624 KB |
Output is correct |
56 |
Runtime error |
21 ms |
14676 KB |
Execution killed with signal 11 |
57 |
Halted |
0 ms |
0 KB |
- |