#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int arr[N],que[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n,ind,q,sum=0,ans=0;
cin>>n >>q;
for(int i=1;i<=n;i++) cin>>arr[i];
for(int i=1;i<=q;i++) cin>>que[i];
if(n*q>=100000000){
for(int i=1;i<=q;i++){
ind=upper_bound(arr+1,arr+n+1,que[i])-arr;
ind--;
long long ans=((1+ind)*ind)/2;
cout<<ans <<"\n";
}
return 0;
}
for(int i=1;i<=q;i++){
ans=0,sum=0;
for(int j=1;j<=n;j++){
if(que[i]>=arr[j]) sum++;
else sum=0;
ans+=sum;
}
cout<<ans <<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
3 ms |
2396 KB |
Output is correct |
23 |
Correct |
2 ms |
2396 KB |
Output is correct |
24 |
Correct |
3 ms |
2396 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4440 KB |
Output is correct |
2 |
Correct |
7 ms |
4444 KB |
Output is correct |
3 |
Correct |
6 ms |
2396 KB |
Output is correct |
4 |
Correct |
6 ms |
2396 KB |
Output is correct |
5 |
Correct |
6 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
5520 KB |
Output is correct |
2 |
Correct |
25 ms |
6748 KB |
Output is correct |
3 |
Correct |
25 ms |
6740 KB |
Output is correct |
4 |
Correct |
25 ms |
8796 KB |
Output is correct |
5 |
Correct |
26 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
5464 KB |
Output is correct |
2 |
Correct |
32 ms |
7004 KB |
Output is correct |
3 |
Correct |
29 ms |
7004 KB |
Output is correct |
4 |
Correct |
29 ms |
8796 KB |
Output is correct |
5 |
Correct |
30 ms |
7004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
6 ms |
4440 KB |
Output is correct |
12 |
Correct |
7 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
2396 KB |
Output is correct |
14 |
Correct |
6 ms |
2396 KB |
Output is correct |
15 |
Correct |
6 ms |
2396 KB |
Output is correct |
16 |
Correct |
6 ms |
2392 KB |
Output is correct |
17 |
Correct |
7 ms |
4444 KB |
Output is correct |
18 |
Correct |
10 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
2392 KB |
Output is correct |
20 |
Correct |
7 ms |
4440 KB |
Output is correct |
21 |
Correct |
6 ms |
2392 KB |
Output is correct |
22 |
Correct |
7 ms |
2392 KB |
Output is correct |
23 |
Correct |
6 ms |
4444 KB |
Output is correct |
24 |
Correct |
6 ms |
2392 KB |
Output is correct |
25 |
Correct |
7 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
3 ms |
2396 KB |
Output is correct |
23 |
Correct |
2 ms |
2396 KB |
Output is correct |
24 |
Correct |
3 ms |
2396 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
26 |
Correct |
6 ms |
4440 KB |
Output is correct |
27 |
Correct |
7 ms |
4444 KB |
Output is correct |
28 |
Correct |
6 ms |
2396 KB |
Output is correct |
29 |
Correct |
6 ms |
2396 KB |
Output is correct |
30 |
Correct |
6 ms |
2396 KB |
Output is correct |
31 |
Correct |
24 ms |
5520 KB |
Output is correct |
32 |
Correct |
25 ms |
6748 KB |
Output is correct |
33 |
Correct |
25 ms |
6740 KB |
Output is correct |
34 |
Correct |
25 ms |
8796 KB |
Output is correct |
35 |
Correct |
26 ms |
6748 KB |
Output is correct |
36 |
Correct |
29 ms |
5464 KB |
Output is correct |
37 |
Correct |
32 ms |
7004 KB |
Output is correct |
38 |
Correct |
29 ms |
7004 KB |
Output is correct |
39 |
Correct |
29 ms |
8796 KB |
Output is correct |
40 |
Correct |
30 ms |
7004 KB |
Output is correct |
41 |
Correct |
6 ms |
2392 KB |
Output is correct |
42 |
Correct |
7 ms |
4444 KB |
Output is correct |
43 |
Correct |
10 ms |
4444 KB |
Output is correct |
44 |
Correct |
6 ms |
2392 KB |
Output is correct |
45 |
Correct |
7 ms |
4440 KB |
Output is correct |
46 |
Correct |
6 ms |
2392 KB |
Output is correct |
47 |
Correct |
7 ms |
2392 KB |
Output is correct |
48 |
Correct |
6 ms |
4444 KB |
Output is correct |
49 |
Correct |
6 ms |
2392 KB |
Output is correct |
50 |
Correct |
7 ms |
4440 KB |
Output is correct |
51 |
Incorrect |
21 ms |
9040 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
3 ms |
2396 KB |
Output is correct |
23 |
Correct |
2 ms |
2396 KB |
Output is correct |
24 |
Correct |
3 ms |
2396 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
26 |
Correct |
6 ms |
4440 KB |
Output is correct |
27 |
Correct |
7 ms |
4444 KB |
Output is correct |
28 |
Correct |
6 ms |
2396 KB |
Output is correct |
29 |
Correct |
6 ms |
2396 KB |
Output is correct |
30 |
Correct |
6 ms |
2396 KB |
Output is correct |
31 |
Correct |
24 ms |
5520 KB |
Output is correct |
32 |
Correct |
25 ms |
6748 KB |
Output is correct |
33 |
Correct |
25 ms |
6740 KB |
Output is correct |
34 |
Correct |
25 ms |
8796 KB |
Output is correct |
35 |
Correct |
26 ms |
6748 KB |
Output is correct |
36 |
Correct |
29 ms |
5464 KB |
Output is correct |
37 |
Correct |
32 ms |
7004 KB |
Output is correct |
38 |
Correct |
29 ms |
7004 KB |
Output is correct |
39 |
Correct |
29 ms |
8796 KB |
Output is correct |
40 |
Correct |
30 ms |
7004 KB |
Output is correct |
41 |
Correct |
6 ms |
2392 KB |
Output is correct |
42 |
Correct |
7 ms |
4444 KB |
Output is correct |
43 |
Correct |
10 ms |
4444 KB |
Output is correct |
44 |
Correct |
6 ms |
2392 KB |
Output is correct |
45 |
Correct |
7 ms |
4440 KB |
Output is correct |
46 |
Correct |
6 ms |
2392 KB |
Output is correct |
47 |
Correct |
7 ms |
2392 KB |
Output is correct |
48 |
Correct |
6 ms |
4444 KB |
Output is correct |
49 |
Correct |
6 ms |
2392 KB |
Output is correct |
50 |
Correct |
7 ms |
4440 KB |
Output is correct |
51 |
Incorrect |
21 ms |
9040 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |