# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1007972 |
2024-06-26T04:07:33 Z |
Luvidi |
Pilot (NOI19_pilot) |
C++17 |
|
985 ms |
90644 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
ll n,q;
cin>>n>>q;
pii h[n], y[q];
for (int i=0;i<n;i++){
cin>>h[i].fs;
h[i].sc=i;
}
for (int i=0;i<q;i++){
cin>>y[i].fs;
y[i].sc=i;
}
sort(h,h+n);
reverse(h,h+n);
sort(y,y+q);
reverse(y,y+q);
ll ans[q];
set<int> r;
r.insert(n-1);
r.insert(-1);
ll idx=0,last=1e6+1,cnt=n*(n+1)/2;
for (int i=0;i<q;i++){
while(last>y[i].fs+1){
last--;
while(h[idx].fs==last){
auto it=r.lower_bound(h[idx].sc);
ll a,b,c;
a=*it;
it--;
b=*it;
c=h[idx].sc;
cnt-=(a-b)*(a-b+1)/2;
cnt+=(a-c)*(a-c+1)/2;
cnt+=(c-b-1)*(c-b)/2;
r.insert(c);
r.insert(c-1);
idx++;
}
}
ans[y[i].sc]=cnt;
}
for (int i=0;i<q;i++)cout<<ans[i]<<'\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
1624 KB |
Output is correct |
2 |
Correct |
12 ms |
1884 KB |
Output is correct |
3 |
Correct |
12 ms |
1724 KB |
Output is correct |
4 |
Correct |
11 ms |
1628 KB |
Output is correct |
5 |
Correct |
12 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
9044 KB |
Output is correct |
2 |
Correct |
56 ms |
9044 KB |
Output is correct |
3 |
Correct |
54 ms |
9044 KB |
Output is correct |
4 |
Correct |
61 ms |
9296 KB |
Output is correct |
5 |
Correct |
52 ms |
8916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
9044 KB |
Output is correct |
2 |
Correct |
57 ms |
9044 KB |
Output is correct |
3 |
Correct |
53 ms |
8936 KB |
Output is correct |
4 |
Correct |
67 ms |
9476 KB |
Output is correct |
5 |
Correct |
65 ms |
9300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
13 ms |
1624 KB |
Output is correct |
12 |
Correct |
12 ms |
1884 KB |
Output is correct |
13 |
Correct |
12 ms |
1724 KB |
Output is correct |
14 |
Correct |
11 ms |
1628 KB |
Output is correct |
15 |
Correct |
12 ms |
1628 KB |
Output is correct |
16 |
Correct |
22 ms |
3672 KB |
Output is correct |
17 |
Correct |
38 ms |
5712 KB |
Output is correct |
18 |
Correct |
47 ms |
6224 KB |
Output is correct |
19 |
Correct |
39 ms |
5936 KB |
Output is correct |
20 |
Correct |
30 ms |
5200 KB |
Output is correct |
21 |
Correct |
12 ms |
1880 KB |
Output is correct |
22 |
Correct |
27 ms |
4696 KB |
Output is correct |
23 |
Correct |
41 ms |
5968 KB |
Output is correct |
24 |
Correct |
36 ms |
5712 KB |
Output is correct |
25 |
Correct |
33 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
26 |
Correct |
13 ms |
1624 KB |
Output is correct |
27 |
Correct |
12 ms |
1884 KB |
Output is correct |
28 |
Correct |
12 ms |
1724 KB |
Output is correct |
29 |
Correct |
11 ms |
1628 KB |
Output is correct |
30 |
Correct |
12 ms |
1628 KB |
Output is correct |
31 |
Correct |
54 ms |
9044 KB |
Output is correct |
32 |
Correct |
56 ms |
9044 KB |
Output is correct |
33 |
Correct |
54 ms |
9044 KB |
Output is correct |
34 |
Correct |
61 ms |
9296 KB |
Output is correct |
35 |
Correct |
52 ms |
8916 KB |
Output is correct |
36 |
Correct |
56 ms |
9044 KB |
Output is correct |
37 |
Correct |
57 ms |
9044 KB |
Output is correct |
38 |
Correct |
53 ms |
8936 KB |
Output is correct |
39 |
Correct |
67 ms |
9476 KB |
Output is correct |
40 |
Correct |
65 ms |
9300 KB |
Output is correct |
41 |
Correct |
22 ms |
3672 KB |
Output is correct |
42 |
Correct |
38 ms |
5712 KB |
Output is correct |
43 |
Correct |
47 ms |
6224 KB |
Output is correct |
44 |
Correct |
39 ms |
5936 KB |
Output is correct |
45 |
Correct |
30 ms |
5200 KB |
Output is correct |
46 |
Correct |
12 ms |
1880 KB |
Output is correct |
47 |
Correct |
27 ms |
4696 KB |
Output is correct |
48 |
Correct |
41 ms |
5968 KB |
Output is correct |
49 |
Correct |
36 ms |
5712 KB |
Output is correct |
50 |
Correct |
33 ms |
4948 KB |
Output is correct |
51 |
Correct |
57 ms |
9040 KB |
Output is correct |
52 |
Correct |
57 ms |
9044 KB |
Output is correct |
53 |
Correct |
56 ms |
9044 KB |
Output is correct |
54 |
Correct |
59 ms |
8840 KB |
Output is correct |
55 |
Correct |
58 ms |
9040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
460 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
26 |
Correct |
13 ms |
1624 KB |
Output is correct |
27 |
Correct |
12 ms |
1884 KB |
Output is correct |
28 |
Correct |
12 ms |
1724 KB |
Output is correct |
29 |
Correct |
11 ms |
1628 KB |
Output is correct |
30 |
Correct |
12 ms |
1628 KB |
Output is correct |
31 |
Correct |
54 ms |
9044 KB |
Output is correct |
32 |
Correct |
56 ms |
9044 KB |
Output is correct |
33 |
Correct |
54 ms |
9044 KB |
Output is correct |
34 |
Correct |
61 ms |
9296 KB |
Output is correct |
35 |
Correct |
52 ms |
8916 KB |
Output is correct |
36 |
Correct |
56 ms |
9044 KB |
Output is correct |
37 |
Correct |
57 ms |
9044 KB |
Output is correct |
38 |
Correct |
53 ms |
8936 KB |
Output is correct |
39 |
Correct |
67 ms |
9476 KB |
Output is correct |
40 |
Correct |
65 ms |
9300 KB |
Output is correct |
41 |
Correct |
22 ms |
3672 KB |
Output is correct |
42 |
Correct |
38 ms |
5712 KB |
Output is correct |
43 |
Correct |
47 ms |
6224 KB |
Output is correct |
44 |
Correct |
39 ms |
5936 KB |
Output is correct |
45 |
Correct |
30 ms |
5200 KB |
Output is correct |
46 |
Correct |
12 ms |
1880 KB |
Output is correct |
47 |
Correct |
27 ms |
4696 KB |
Output is correct |
48 |
Correct |
41 ms |
5968 KB |
Output is correct |
49 |
Correct |
36 ms |
5712 KB |
Output is correct |
50 |
Correct |
33 ms |
4948 KB |
Output is correct |
51 |
Correct |
57 ms |
9040 KB |
Output is correct |
52 |
Correct |
57 ms |
9044 KB |
Output is correct |
53 |
Correct |
56 ms |
9044 KB |
Output is correct |
54 |
Correct |
59 ms |
8840 KB |
Output is correct |
55 |
Correct |
58 ms |
9040 KB |
Output is correct |
56 |
Correct |
973 ms |
87888 KB |
Output is correct |
57 |
Correct |
963 ms |
88912 KB |
Output is correct |
58 |
Correct |
938 ms |
83108 KB |
Output is correct |
59 |
Correct |
915 ms |
85388 KB |
Output is correct |
60 |
Correct |
985 ms |
90644 KB |
Output is correct |