#include<bits/stdc++.h>
#define deb(x) cout<<#x<<": "<<x<<endl
using namespace std;
int main(){
long long n,q;
cin>>n>>q;
long long heights[n+1],planes[q];
for(int i=0;i<n;i++) cin>>heights[i];
for(int i=0;i<q;i++) cin>>planes[i];
heights[n]=1e9;
if(is_sorted(heights,heights+n+1)){
for(int i=0;i<q;i++){
long long reach_height=planes[i];
long long count=0,ans=0;
for(int j=0;j<n+1;j++){
if(heights[j]<=reach_height) count++;
else{
ans+=count*(count+1)/2;
break;
}
}
cout<<ans<<endl;
}
}
else{
for(int i=0;i<q;i++){
long long reach_height=planes[i];
long long count=0,ans=0;
for(int j=0;j<n+1;j++){
if(heights[j]<=reach_height) count++;
else{
ans+=count*(count+1)/2;
count=0;
}
}
cout<<ans<<endl;
}
}
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
0 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
0 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
0 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
5 ms |
364 KB |
Output is correct |
22 |
Correct |
6 ms |
364 KB |
Output is correct |
23 |
Correct |
5 ms |
364 KB |
Output is correct |
24 |
Correct |
6 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1004 KB |
Output is correct |
2 |
Correct |
32 ms |
1132 KB |
Output is correct |
3 |
Correct |
27 ms |
1004 KB |
Output is correct |
4 |
Correct |
29 ms |
996 KB |
Output is correct |
5 |
Correct |
27 ms |
1004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
2016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1046 ms |
2176 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
37 ms |
1004 KB |
Output is correct |
12 |
Correct |
32 ms |
1132 KB |
Output is correct |
13 |
Correct |
27 ms |
1004 KB |
Output is correct |
14 |
Correct |
29 ms |
996 KB |
Output is correct |
15 |
Correct |
27 ms |
1004 KB |
Output is correct |
16 |
Correct |
27 ms |
996 KB |
Output is correct |
17 |
Correct |
31 ms |
1132 KB |
Output is correct |
18 |
Correct |
32 ms |
1124 KB |
Output is correct |
19 |
Correct |
26 ms |
996 KB |
Output is correct |
20 |
Correct |
31 ms |
1004 KB |
Output is correct |
21 |
Correct |
26 ms |
1004 KB |
Output is correct |
22 |
Correct |
30 ms |
1004 KB |
Output is correct |
23 |
Correct |
29 ms |
1124 KB |
Output is correct |
24 |
Correct |
32 ms |
996 KB |
Output is correct |
25 |
Correct |
32 ms |
1124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
0 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
5 ms |
364 KB |
Output is correct |
22 |
Correct |
6 ms |
364 KB |
Output is correct |
23 |
Correct |
5 ms |
364 KB |
Output is correct |
24 |
Correct |
6 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
37 ms |
1004 KB |
Output is correct |
27 |
Correct |
32 ms |
1132 KB |
Output is correct |
28 |
Correct |
27 ms |
1004 KB |
Output is correct |
29 |
Correct |
29 ms |
996 KB |
Output is correct |
30 |
Correct |
27 ms |
1004 KB |
Output is correct |
31 |
Execution timed out |
1073 ms |
2016 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
0 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
5 ms |
364 KB |
Output is correct |
22 |
Correct |
6 ms |
364 KB |
Output is correct |
23 |
Correct |
5 ms |
364 KB |
Output is correct |
24 |
Correct |
6 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
37 ms |
1004 KB |
Output is correct |
27 |
Correct |
32 ms |
1132 KB |
Output is correct |
28 |
Correct |
27 ms |
1004 KB |
Output is correct |
29 |
Correct |
29 ms |
996 KB |
Output is correct |
30 |
Correct |
27 ms |
1004 KB |
Output is correct |
31 |
Execution timed out |
1073 ms |
2016 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |