# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
373432 | 2021-03-04T14:46:34 Z | cpp219 | Pilot (NOI19_pilot) | C++14 | 842 ms | 68388 KB |
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 1e6 + 9; const ll inf = 1e16 + 7; LL q[N]; ll n,Q,ans[N],lab[N],cur,a[N]; deque<ll> dq; ll Find(ll u){ if (lab[u] < 0) return u; return lab[u] = Find(lab[u]); } void Union(ll p,ll q){ ll r = Find(p),s = Find(q); if (r == s) return; cur += lab[r]*lab[s]; if (lab[r] > lab[s]) swap(r,s); lab[r] += lab[s]; lab[s] = r; } bool lf(ll x,ll y){ return a[x] < a[y]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n>>Q; memset(lab,-1,sizeof(lab)); for (ll i = 1;i <= n;i++) cin>>a[i],dq.push_back(i); sort(dq.begin(),dq.end(),lf); for (ll i = 1;i <= Q;i++) cin>>q[i].fs,q[i].sc = i; sort(q + 1,q + Q + 1); for (ll i = 1;i <= Q;i++){ while(!dq.empty()){ ll t = dq.front(); if (a[t] > q[i].fs) break; dq.pop_front(); cur++; if (t != 1&&a[t - 1] <= q[i].fs) Union(t,t - 1); if (t != n&&a[t + 1] <= q[i].fs) Union(t,t + 1); } ans[q[i].sc] = cur; } for (ll i = 1;i <= Q;i++) cout<<ans[i]<<"\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8300 KB | Output is correct |
2 | Correct | 4 ms | 8172 KB | Output is correct |
3 | Correct | 4 ms | 8172 KB | Output is correct |
4 | Correct | 6 ms | 8172 KB | Output is correct |
5 | Correct | 4 ms | 8172 KB | Output is correct |
6 | Correct | 5 ms | 8184 KB | Output is correct |
7 | Correct | 5 ms | 8172 KB | Output is correct |
8 | Correct | 6 ms | 8172 KB | Output is correct |
9 | Correct | 4 ms | 8172 KB | Output is correct |
10 | Correct | 5 ms | 8172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8300 KB | Output is correct |
2 | Correct | 4 ms | 8172 KB | Output is correct |
3 | Correct | 4 ms | 8172 KB | Output is correct |
4 | Correct | 6 ms | 8172 KB | Output is correct |
5 | Correct | 4 ms | 8172 KB | Output is correct |
6 | Correct | 5 ms | 8184 KB | Output is correct |
7 | Correct | 5 ms | 8172 KB | Output is correct |
8 | Correct | 6 ms | 8172 KB | Output is correct |
9 | Correct | 4 ms | 8172 KB | Output is correct |
10 | Correct | 5 ms | 8172 KB | Output is correct |
11 | Correct | 4 ms | 8300 KB | Output is correct |
12 | Correct | 14 ms | 8300 KB | Output is correct |
13 | Correct | 5 ms | 8172 KB | Output is correct |
14 | Correct | 5 ms | 8172 KB | Output is correct |
15 | Correct | 5 ms | 8172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8300 KB | Output is correct |
2 | Correct | 4 ms | 8172 KB | Output is correct |
3 | Correct | 4 ms | 8172 KB | Output is correct |
4 | Correct | 6 ms | 8172 KB | Output is correct |
5 | Correct | 4 ms | 8172 KB | Output is correct |
6 | Correct | 5 ms | 8184 KB | Output is correct |
7 | Correct | 5 ms | 8172 KB | Output is correct |
8 | Correct | 6 ms | 8172 KB | Output is correct |
9 | Correct | 4 ms | 8172 KB | Output is correct |
10 | Correct | 5 ms | 8172 KB | Output is correct |
11 | Correct | 4 ms | 8300 KB | Output is correct |
12 | Correct | 14 ms | 8300 KB | Output is correct |
13 | Correct | 5 ms | 8172 KB | Output is correct |
14 | Correct | 5 ms | 8172 KB | Output is correct |
15 | Correct | 5 ms | 8172 KB | Output is correct |
16 | Correct | 6 ms | 8172 KB | Output is correct |
17 | Correct | 5 ms | 8172 KB | Output is correct |
18 | Correct | 5 ms | 8192 KB | Output is correct |
19 | Correct | 5 ms | 8172 KB | Output is correct |
20 | Correct | 5 ms | 8172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8300 KB | Output is correct |
2 | Correct | 4 ms | 8172 KB | Output is correct |
3 | Correct | 4 ms | 8172 KB | Output is correct |
4 | Correct | 6 ms | 8172 KB | Output is correct |
5 | Correct | 4 ms | 8172 KB | Output is correct |
6 | Correct | 5 ms | 8184 KB | Output is correct |
7 | Correct | 5 ms | 8172 KB | Output is correct |
8 | Correct | 6 ms | 8172 KB | Output is correct |
9 | Correct | 4 ms | 8172 KB | Output is correct |
10 | Correct | 5 ms | 8172 KB | Output is correct |
11 | Correct | 4 ms | 8300 KB | Output is correct |
12 | Correct | 14 ms | 8300 KB | Output is correct |
13 | Correct | 5 ms | 8172 KB | Output is correct |
14 | Correct | 5 ms | 8172 KB | Output is correct |
15 | Correct | 5 ms | 8172 KB | Output is correct |
16 | Correct | 6 ms | 8172 KB | Output is correct |
17 | Correct | 5 ms | 8172 KB | Output is correct |
18 | Correct | 5 ms | 8192 KB | Output is correct |
19 | Correct | 5 ms | 8172 KB | Output is correct |
20 | Correct | 5 ms | 8172 KB | Output is correct |
21 | Correct | 6 ms | 8300 KB | Output is correct |
22 | Correct | 6 ms | 8300 KB | Output is correct |
23 | Correct | 6 ms | 8300 KB | Output is correct |
24 | Correct | 6 ms | 8300 KB | Output is correct |
25 | Correct | 5 ms | 8300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 10364 KB | Output is correct |
2 | Correct | 37 ms | 10476 KB | Output is correct |
3 | Correct | 34 ms | 10220 KB | Output is correct |
4 | Correct | 34 ms | 10220 KB | Output is correct |
5 | Correct | 34 ms | 10348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 13932 KB | Output is correct |
2 | Correct | 53 ms | 14188 KB | Output is correct |
3 | Correct | 51 ms | 14060 KB | Output is correct |
4 | Correct | 67 ms | 14060 KB | Output is correct |
5 | Correct | 51 ms | 13932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 14188 KB | Output is correct |
2 | Correct | 53 ms | 14060 KB | Output is correct |
3 | Correct | 53 ms | 14188 KB | Output is correct |
4 | Correct | 53 ms | 14188 KB | Output is correct |
5 | Correct | 58 ms | 14444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8300 KB | Output is correct |
2 | Correct | 4 ms | 8172 KB | Output is correct |
3 | Correct | 4 ms | 8172 KB | Output is correct |
4 | Correct | 6 ms | 8172 KB | Output is correct |
5 | Correct | 4 ms | 8172 KB | Output is correct |
6 | Correct | 5 ms | 8184 KB | Output is correct |
7 | Correct | 5 ms | 8172 KB | Output is correct |
8 | Correct | 6 ms | 8172 KB | Output is correct |
9 | Correct | 4 ms | 8172 KB | Output is correct |
10 | Correct | 5 ms | 8172 KB | Output is correct |
11 | Correct | 36 ms | 10364 KB | Output is correct |
12 | Correct | 37 ms | 10476 KB | Output is correct |
13 | Correct | 34 ms | 10220 KB | Output is correct |
14 | Correct | 34 ms | 10220 KB | Output is correct |
15 | Correct | 34 ms | 10348 KB | Output is correct |
16 | Correct | 32 ms | 10220 KB | Output is correct |
17 | Correct | 38 ms | 10604 KB | Output is correct |
18 | Correct | 33 ms | 10476 KB | Output is correct |
19 | Correct | 29 ms | 10220 KB | Output is correct |
20 | Correct | 33 ms | 10348 KB | Output is correct |
21 | Correct | 35 ms | 10220 KB | Output is correct |
22 | Correct | 32 ms | 10348 KB | Output is correct |
23 | Correct | 32 ms | 10348 KB | Output is correct |
24 | Correct | 30 ms | 10348 KB | Output is correct |
25 | Correct | 32 ms | 10348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8300 KB | Output is correct |
2 | Correct | 4 ms | 8172 KB | Output is correct |
3 | Correct | 4 ms | 8172 KB | Output is correct |
4 | Correct | 6 ms | 8172 KB | Output is correct |
5 | Correct | 4 ms | 8172 KB | Output is correct |
6 | Correct | 5 ms | 8184 KB | Output is correct |
7 | Correct | 5 ms | 8172 KB | Output is correct |
8 | Correct | 6 ms | 8172 KB | Output is correct |
9 | Correct | 4 ms | 8172 KB | Output is correct |
10 | Correct | 5 ms | 8172 KB | Output is correct |
11 | Correct | 4 ms | 8300 KB | Output is correct |
12 | Correct | 14 ms | 8300 KB | Output is correct |
13 | Correct | 5 ms | 8172 KB | Output is correct |
14 | Correct | 5 ms | 8172 KB | Output is correct |
15 | Correct | 5 ms | 8172 KB | Output is correct |
16 | Correct | 6 ms | 8172 KB | Output is correct |
17 | Correct | 5 ms | 8172 KB | Output is correct |
18 | Correct | 5 ms | 8192 KB | Output is correct |
19 | Correct | 5 ms | 8172 KB | Output is correct |
20 | Correct | 5 ms | 8172 KB | Output is correct |
21 | Correct | 6 ms | 8300 KB | Output is correct |
22 | Correct | 6 ms | 8300 KB | Output is correct |
23 | Correct | 6 ms | 8300 KB | Output is correct |
24 | Correct | 6 ms | 8300 KB | Output is correct |
25 | Correct | 5 ms | 8300 KB | Output is correct |
26 | Correct | 36 ms | 10364 KB | Output is correct |
27 | Correct | 37 ms | 10476 KB | Output is correct |
28 | Correct | 34 ms | 10220 KB | Output is correct |
29 | Correct | 34 ms | 10220 KB | Output is correct |
30 | Correct | 34 ms | 10348 KB | Output is correct |
31 | Correct | 50 ms | 13932 KB | Output is correct |
32 | Correct | 53 ms | 14188 KB | Output is correct |
33 | Correct | 51 ms | 14060 KB | Output is correct |
34 | Correct | 67 ms | 14060 KB | Output is correct |
35 | Correct | 51 ms | 13932 KB | Output is correct |
36 | Correct | 53 ms | 14188 KB | Output is correct |
37 | Correct | 53 ms | 14060 KB | Output is correct |
38 | Correct | 53 ms | 14188 KB | Output is correct |
39 | Correct | 53 ms | 14188 KB | Output is correct |
40 | Correct | 58 ms | 14444 KB | Output is correct |
41 | Correct | 32 ms | 10220 KB | Output is correct |
42 | Correct | 38 ms | 10604 KB | Output is correct |
43 | Correct | 33 ms | 10476 KB | Output is correct |
44 | Correct | 29 ms | 10220 KB | Output is correct |
45 | Correct | 33 ms | 10348 KB | Output is correct |
46 | Correct | 35 ms | 10220 KB | Output is correct |
47 | Correct | 32 ms | 10348 KB | Output is correct |
48 | Correct | 32 ms | 10348 KB | Output is correct |
49 | Correct | 30 ms | 10348 KB | Output is correct |
50 | Correct | 32 ms | 10348 KB | Output is correct |
51 | Correct | 66 ms | 14060 KB | Output is correct |
52 | Correct | 64 ms | 13932 KB | Output is correct |
53 | Correct | 65 ms | 13932 KB | Output is correct |
54 | Correct | 63 ms | 13956 KB | Output is correct |
55 | Correct | 71 ms | 13932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8300 KB | Output is correct |
2 | Correct | 4 ms | 8172 KB | Output is correct |
3 | Correct | 4 ms | 8172 KB | Output is correct |
4 | Correct | 6 ms | 8172 KB | Output is correct |
5 | Correct | 4 ms | 8172 KB | Output is correct |
6 | Correct | 5 ms | 8184 KB | Output is correct |
7 | Correct | 5 ms | 8172 KB | Output is correct |
8 | Correct | 6 ms | 8172 KB | Output is correct |
9 | Correct | 4 ms | 8172 KB | Output is correct |
10 | Correct | 5 ms | 8172 KB | Output is correct |
11 | Correct | 4 ms | 8300 KB | Output is correct |
12 | Correct | 14 ms | 8300 KB | Output is correct |
13 | Correct | 5 ms | 8172 KB | Output is correct |
14 | Correct | 5 ms | 8172 KB | Output is correct |
15 | Correct | 5 ms | 8172 KB | Output is correct |
16 | Correct | 6 ms | 8172 KB | Output is correct |
17 | Correct | 5 ms | 8172 KB | Output is correct |
18 | Correct | 5 ms | 8192 KB | Output is correct |
19 | Correct | 5 ms | 8172 KB | Output is correct |
20 | Correct | 5 ms | 8172 KB | Output is correct |
21 | Correct | 6 ms | 8300 KB | Output is correct |
22 | Correct | 6 ms | 8300 KB | Output is correct |
23 | Correct | 6 ms | 8300 KB | Output is correct |
24 | Correct | 6 ms | 8300 KB | Output is correct |
25 | Correct | 5 ms | 8300 KB | Output is correct |
26 | Correct | 36 ms | 10364 KB | Output is correct |
27 | Correct | 37 ms | 10476 KB | Output is correct |
28 | Correct | 34 ms | 10220 KB | Output is correct |
29 | Correct | 34 ms | 10220 KB | Output is correct |
30 | Correct | 34 ms | 10348 KB | Output is correct |
31 | Correct | 50 ms | 13932 KB | Output is correct |
32 | Correct | 53 ms | 14188 KB | Output is correct |
33 | Correct | 51 ms | 14060 KB | Output is correct |
34 | Correct | 67 ms | 14060 KB | Output is correct |
35 | Correct | 51 ms | 13932 KB | Output is correct |
36 | Correct | 53 ms | 14188 KB | Output is correct |
37 | Correct | 53 ms | 14060 KB | Output is correct |
38 | Correct | 53 ms | 14188 KB | Output is correct |
39 | Correct | 53 ms | 14188 KB | Output is correct |
40 | Correct | 58 ms | 14444 KB | Output is correct |
41 | Correct | 32 ms | 10220 KB | Output is correct |
42 | Correct | 38 ms | 10604 KB | Output is correct |
43 | Correct | 33 ms | 10476 KB | Output is correct |
44 | Correct | 29 ms | 10220 KB | Output is correct |
45 | Correct | 33 ms | 10348 KB | Output is correct |
46 | Correct | 35 ms | 10220 KB | Output is correct |
47 | Correct | 32 ms | 10348 KB | Output is correct |
48 | Correct | 32 ms | 10348 KB | Output is correct |
49 | Correct | 30 ms | 10348 KB | Output is correct |
50 | Correct | 32 ms | 10348 KB | Output is correct |
51 | Correct | 66 ms | 14060 KB | Output is correct |
52 | Correct | 64 ms | 13932 KB | Output is correct |
53 | Correct | 65 ms | 13932 KB | Output is correct |
54 | Correct | 63 ms | 13956 KB | Output is correct |
55 | Correct | 71 ms | 13932 KB | Output is correct |
56 | Correct | 823 ms | 67324 KB | Output is correct |
57 | Correct | 818 ms | 66300 KB | Output is correct |
58 | Correct | 760 ms | 63228 KB | Output is correct |
59 | Correct | 781 ms | 64508 KB | Output is correct |
60 | Correct | 842 ms | 68388 KB | Output is correct |