# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
209774 |
2020-03-15T14:09:15 Z |
Alexa2001 |
Pilot (NOI19_pilot) |
C++17 |
|
1000 ms |
107648 KB |
#include <bits/stdc++.h>
using namespace std;
/// 16:02
typedef long long ll;
const int Nmax = 1e6 + 5;
ll act = 0;
vector<int> v[Nmax], w[Nmax];
int n, q;
ll ans[Nmax];
int t[Nmax], sz[Nmax];
ll take2(int x)
{
return (ll)x*(x+1)/2;
}
int boss(int x)
{
if(x == t[x]) return x;
return t[x] = boss(t[x]);
}
void unite(int x, int y)
{
x = boss(x); y = boss(y);
act -= take2(sz[y]) + take2(sz[x]);
if(sz[x] > sz[y]) swap(x, y);
t[x] = y;
sz[y] += sz[x];
act += take2(sz[y]);
}
void add(int x)
{
sz[x] = 1; t[x] = x;
++act;
if(sz[x-1]) unite(x, x-1);
if(sz[x+1]) unite(x, x+1);
}
int main()
{
// freopen("input", "r", stdin);
cin.sync_with_stdio(false); cin.tie(0);
cin >> n >> q;
int i;
for(i=1; i<=n; ++i)
{
int x;
cin >> x;
w[x].push_back(i);
}
for(i=1; i<=q; ++i)
{
int x;
cin >> x;
v[x].push_back(i);
}
for(i=1; i<=Nmax-5; ++i)
{
for(auto it : w[i]) add(it);
for(auto it : v[i]) ans[it] = act;
}
for(i=1; i<=q; ++i) cout << ans[i] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47352 KB |
Output is correct |
2 |
Correct |
36 ms |
47356 KB |
Output is correct |
3 |
Correct |
38 ms |
47352 KB |
Output is correct |
4 |
Correct |
38 ms |
47352 KB |
Output is correct |
5 |
Correct |
37 ms |
47352 KB |
Output is correct |
6 |
Correct |
37 ms |
47352 KB |
Output is correct |
7 |
Correct |
37 ms |
47352 KB |
Output is correct |
8 |
Correct |
37 ms |
47352 KB |
Output is correct |
9 |
Correct |
38 ms |
47352 KB |
Output is correct |
10 |
Correct |
36 ms |
47352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47352 KB |
Output is correct |
2 |
Correct |
36 ms |
47356 KB |
Output is correct |
3 |
Correct |
38 ms |
47352 KB |
Output is correct |
4 |
Correct |
38 ms |
47352 KB |
Output is correct |
5 |
Correct |
37 ms |
47352 KB |
Output is correct |
6 |
Correct |
37 ms |
47352 KB |
Output is correct |
7 |
Correct |
37 ms |
47352 KB |
Output is correct |
8 |
Correct |
37 ms |
47352 KB |
Output is correct |
9 |
Correct |
38 ms |
47352 KB |
Output is correct |
10 |
Correct |
36 ms |
47352 KB |
Output is correct |
11 |
Correct |
38 ms |
47352 KB |
Output is correct |
12 |
Correct |
38 ms |
47352 KB |
Output is correct |
13 |
Correct |
37 ms |
47352 KB |
Output is correct |
14 |
Correct |
37 ms |
47352 KB |
Output is correct |
15 |
Correct |
36 ms |
47352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47352 KB |
Output is correct |
2 |
Correct |
36 ms |
47356 KB |
Output is correct |
3 |
Correct |
38 ms |
47352 KB |
Output is correct |
4 |
Correct |
38 ms |
47352 KB |
Output is correct |
5 |
Correct |
37 ms |
47352 KB |
Output is correct |
6 |
Correct |
37 ms |
47352 KB |
Output is correct |
7 |
Correct |
37 ms |
47352 KB |
Output is correct |
8 |
Correct |
37 ms |
47352 KB |
Output is correct |
9 |
Correct |
38 ms |
47352 KB |
Output is correct |
10 |
Correct |
36 ms |
47352 KB |
Output is correct |
11 |
Correct |
38 ms |
47352 KB |
Output is correct |
12 |
Correct |
38 ms |
47352 KB |
Output is correct |
13 |
Correct |
37 ms |
47352 KB |
Output is correct |
14 |
Correct |
37 ms |
47352 KB |
Output is correct |
15 |
Correct |
36 ms |
47352 KB |
Output is correct |
16 |
Correct |
36 ms |
47352 KB |
Output is correct |
17 |
Correct |
38 ms |
47352 KB |
Output is correct |
18 |
Correct |
37 ms |
47352 KB |
Output is correct |
19 |
Correct |
37 ms |
47352 KB |
Output is correct |
20 |
Correct |
37 ms |
47352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47352 KB |
Output is correct |
2 |
Correct |
36 ms |
47356 KB |
Output is correct |
3 |
Correct |
38 ms |
47352 KB |
Output is correct |
4 |
Correct |
38 ms |
47352 KB |
Output is correct |
5 |
Correct |
37 ms |
47352 KB |
Output is correct |
6 |
Correct |
37 ms |
47352 KB |
Output is correct |
7 |
Correct |
37 ms |
47352 KB |
Output is correct |
8 |
Correct |
37 ms |
47352 KB |
Output is correct |
9 |
Correct |
38 ms |
47352 KB |
Output is correct |
10 |
Correct |
36 ms |
47352 KB |
Output is correct |
11 |
Correct |
38 ms |
47352 KB |
Output is correct |
12 |
Correct |
38 ms |
47352 KB |
Output is correct |
13 |
Correct |
37 ms |
47352 KB |
Output is correct |
14 |
Correct |
37 ms |
47352 KB |
Output is correct |
15 |
Correct |
36 ms |
47352 KB |
Output is correct |
16 |
Correct |
36 ms |
47352 KB |
Output is correct |
17 |
Correct |
38 ms |
47352 KB |
Output is correct |
18 |
Correct |
37 ms |
47352 KB |
Output is correct |
19 |
Correct |
37 ms |
47352 KB |
Output is correct |
20 |
Correct |
37 ms |
47352 KB |
Output is correct |
21 |
Correct |
41 ms |
47352 KB |
Output is correct |
22 |
Correct |
39 ms |
47352 KB |
Output is correct |
23 |
Correct |
37 ms |
47352 KB |
Output is correct |
24 |
Correct |
38 ms |
47352 KB |
Output is correct |
25 |
Correct |
39 ms |
47224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
50040 KB |
Output is correct |
2 |
Correct |
85 ms |
51064 KB |
Output is correct |
3 |
Correct |
63 ms |
49912 KB |
Output is correct |
4 |
Correct |
81 ms |
50768 KB |
Output is correct |
5 |
Correct |
63 ms |
49912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
55160 KB |
Output is correct |
2 |
Correct |
105 ms |
55288 KB |
Output is correct |
3 |
Correct |
104 ms |
55288 KB |
Output is correct |
4 |
Correct |
100 ms |
55416 KB |
Output is correct |
5 |
Correct |
103 ms |
55184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
55292 KB |
Output is correct |
2 |
Correct |
112 ms |
55288 KB |
Output is correct |
3 |
Correct |
112 ms |
55380 KB |
Output is correct |
4 |
Correct |
110 ms |
55416 KB |
Output is correct |
5 |
Correct |
115 ms |
55672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47352 KB |
Output is correct |
2 |
Correct |
36 ms |
47356 KB |
Output is correct |
3 |
Correct |
38 ms |
47352 KB |
Output is correct |
4 |
Correct |
38 ms |
47352 KB |
Output is correct |
5 |
Correct |
37 ms |
47352 KB |
Output is correct |
6 |
Correct |
37 ms |
47352 KB |
Output is correct |
7 |
Correct |
37 ms |
47352 KB |
Output is correct |
8 |
Correct |
37 ms |
47352 KB |
Output is correct |
9 |
Correct |
38 ms |
47352 KB |
Output is correct |
10 |
Correct |
36 ms |
47352 KB |
Output is correct |
11 |
Correct |
66 ms |
50040 KB |
Output is correct |
12 |
Correct |
85 ms |
51064 KB |
Output is correct |
13 |
Correct |
63 ms |
49912 KB |
Output is correct |
14 |
Correct |
81 ms |
50768 KB |
Output is correct |
15 |
Correct |
63 ms |
49912 KB |
Output is correct |
16 |
Correct |
63 ms |
49912 KB |
Output is correct |
17 |
Correct |
84 ms |
50936 KB |
Output is correct |
18 |
Correct |
89 ms |
51068 KB |
Output is correct |
19 |
Correct |
63 ms |
49912 KB |
Output is correct |
20 |
Correct |
86 ms |
50940 KB |
Output is correct |
21 |
Correct |
65 ms |
49784 KB |
Output is correct |
22 |
Correct |
81 ms |
50860 KB |
Output is correct |
23 |
Correct |
64 ms |
50040 KB |
Output is correct |
24 |
Correct |
85 ms |
50776 KB |
Output is correct |
25 |
Correct |
65 ms |
50040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47352 KB |
Output is correct |
2 |
Correct |
36 ms |
47356 KB |
Output is correct |
3 |
Correct |
38 ms |
47352 KB |
Output is correct |
4 |
Correct |
38 ms |
47352 KB |
Output is correct |
5 |
Correct |
37 ms |
47352 KB |
Output is correct |
6 |
Correct |
37 ms |
47352 KB |
Output is correct |
7 |
Correct |
37 ms |
47352 KB |
Output is correct |
8 |
Correct |
37 ms |
47352 KB |
Output is correct |
9 |
Correct |
38 ms |
47352 KB |
Output is correct |
10 |
Correct |
36 ms |
47352 KB |
Output is correct |
11 |
Correct |
38 ms |
47352 KB |
Output is correct |
12 |
Correct |
38 ms |
47352 KB |
Output is correct |
13 |
Correct |
37 ms |
47352 KB |
Output is correct |
14 |
Correct |
37 ms |
47352 KB |
Output is correct |
15 |
Correct |
36 ms |
47352 KB |
Output is correct |
16 |
Correct |
36 ms |
47352 KB |
Output is correct |
17 |
Correct |
38 ms |
47352 KB |
Output is correct |
18 |
Correct |
37 ms |
47352 KB |
Output is correct |
19 |
Correct |
37 ms |
47352 KB |
Output is correct |
20 |
Correct |
37 ms |
47352 KB |
Output is correct |
21 |
Correct |
41 ms |
47352 KB |
Output is correct |
22 |
Correct |
39 ms |
47352 KB |
Output is correct |
23 |
Correct |
37 ms |
47352 KB |
Output is correct |
24 |
Correct |
38 ms |
47352 KB |
Output is correct |
25 |
Correct |
39 ms |
47224 KB |
Output is correct |
26 |
Correct |
66 ms |
50040 KB |
Output is correct |
27 |
Correct |
85 ms |
51064 KB |
Output is correct |
28 |
Correct |
63 ms |
49912 KB |
Output is correct |
29 |
Correct |
81 ms |
50768 KB |
Output is correct |
30 |
Correct |
63 ms |
49912 KB |
Output is correct |
31 |
Correct |
102 ms |
55160 KB |
Output is correct |
32 |
Correct |
105 ms |
55288 KB |
Output is correct |
33 |
Correct |
104 ms |
55288 KB |
Output is correct |
34 |
Correct |
100 ms |
55416 KB |
Output is correct |
35 |
Correct |
103 ms |
55184 KB |
Output is correct |
36 |
Correct |
109 ms |
55292 KB |
Output is correct |
37 |
Correct |
112 ms |
55288 KB |
Output is correct |
38 |
Correct |
112 ms |
55380 KB |
Output is correct |
39 |
Correct |
110 ms |
55416 KB |
Output is correct |
40 |
Correct |
115 ms |
55672 KB |
Output is correct |
41 |
Correct |
63 ms |
49912 KB |
Output is correct |
42 |
Correct |
84 ms |
50936 KB |
Output is correct |
43 |
Correct |
89 ms |
51068 KB |
Output is correct |
44 |
Correct |
63 ms |
49912 KB |
Output is correct |
45 |
Correct |
86 ms |
50940 KB |
Output is correct |
46 |
Correct |
65 ms |
49784 KB |
Output is correct |
47 |
Correct |
81 ms |
50860 KB |
Output is correct |
48 |
Correct |
64 ms |
50040 KB |
Output is correct |
49 |
Correct |
85 ms |
50776 KB |
Output is correct |
50 |
Correct |
65 ms |
50040 KB |
Output is correct |
51 |
Correct |
114 ms |
54136 KB |
Output is correct |
52 |
Correct |
140 ms |
55032 KB |
Output is correct |
53 |
Correct |
116 ms |
54008 KB |
Output is correct |
54 |
Correct |
132 ms |
54904 KB |
Output is correct |
55 |
Correct |
128 ms |
54008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47352 KB |
Output is correct |
2 |
Correct |
36 ms |
47356 KB |
Output is correct |
3 |
Correct |
38 ms |
47352 KB |
Output is correct |
4 |
Correct |
38 ms |
47352 KB |
Output is correct |
5 |
Correct |
37 ms |
47352 KB |
Output is correct |
6 |
Correct |
37 ms |
47352 KB |
Output is correct |
7 |
Correct |
37 ms |
47352 KB |
Output is correct |
8 |
Correct |
37 ms |
47352 KB |
Output is correct |
9 |
Correct |
38 ms |
47352 KB |
Output is correct |
10 |
Correct |
36 ms |
47352 KB |
Output is correct |
11 |
Correct |
38 ms |
47352 KB |
Output is correct |
12 |
Correct |
38 ms |
47352 KB |
Output is correct |
13 |
Correct |
37 ms |
47352 KB |
Output is correct |
14 |
Correct |
37 ms |
47352 KB |
Output is correct |
15 |
Correct |
36 ms |
47352 KB |
Output is correct |
16 |
Correct |
36 ms |
47352 KB |
Output is correct |
17 |
Correct |
38 ms |
47352 KB |
Output is correct |
18 |
Correct |
37 ms |
47352 KB |
Output is correct |
19 |
Correct |
37 ms |
47352 KB |
Output is correct |
20 |
Correct |
37 ms |
47352 KB |
Output is correct |
21 |
Correct |
41 ms |
47352 KB |
Output is correct |
22 |
Correct |
39 ms |
47352 KB |
Output is correct |
23 |
Correct |
37 ms |
47352 KB |
Output is correct |
24 |
Correct |
38 ms |
47352 KB |
Output is correct |
25 |
Correct |
39 ms |
47224 KB |
Output is correct |
26 |
Correct |
66 ms |
50040 KB |
Output is correct |
27 |
Correct |
85 ms |
51064 KB |
Output is correct |
28 |
Correct |
63 ms |
49912 KB |
Output is correct |
29 |
Correct |
81 ms |
50768 KB |
Output is correct |
30 |
Correct |
63 ms |
49912 KB |
Output is correct |
31 |
Correct |
102 ms |
55160 KB |
Output is correct |
32 |
Correct |
105 ms |
55288 KB |
Output is correct |
33 |
Correct |
104 ms |
55288 KB |
Output is correct |
34 |
Correct |
100 ms |
55416 KB |
Output is correct |
35 |
Correct |
103 ms |
55184 KB |
Output is correct |
36 |
Correct |
109 ms |
55292 KB |
Output is correct |
37 |
Correct |
112 ms |
55288 KB |
Output is correct |
38 |
Correct |
112 ms |
55380 KB |
Output is correct |
39 |
Correct |
110 ms |
55416 KB |
Output is correct |
40 |
Correct |
115 ms |
55672 KB |
Output is correct |
41 |
Correct |
63 ms |
49912 KB |
Output is correct |
42 |
Correct |
84 ms |
50936 KB |
Output is correct |
43 |
Correct |
89 ms |
51068 KB |
Output is correct |
44 |
Correct |
63 ms |
49912 KB |
Output is correct |
45 |
Correct |
86 ms |
50940 KB |
Output is correct |
46 |
Correct |
65 ms |
49784 KB |
Output is correct |
47 |
Correct |
81 ms |
50860 KB |
Output is correct |
48 |
Correct |
64 ms |
50040 KB |
Output is correct |
49 |
Correct |
85 ms |
50776 KB |
Output is correct |
50 |
Correct |
65 ms |
50040 KB |
Output is correct |
51 |
Correct |
114 ms |
54136 KB |
Output is correct |
52 |
Correct |
140 ms |
55032 KB |
Output is correct |
53 |
Correct |
116 ms |
54008 KB |
Output is correct |
54 |
Correct |
132 ms |
54904 KB |
Output is correct |
55 |
Correct |
128 ms |
54008 KB |
Output is correct |
56 |
Execution timed out |
1096 ms |
107648 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |