#include <bits/stdc++.h>
using namespace std;
#define LIFESUCKS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define ar array
#include<cstdio>
#define vt vector
#include<fstream>
ifstream fin("closing.in");
ofstream fout("closing.out");
#include<fstream>
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vt vector
using namespace std;
int main()
{
int n, q; cin >> n >> q;
ll a[n];
for(int i = 0; i < n; i++)cin >> a[i];
if(n <= 1000 || q == 1){
for(int i = 0; i < q; i++){
ll x; cin >> x;
ll res = 0;
ll cr = 0;
for(int j = 0; j < n; j++){
if(a[j] <= x)cr++;
else{
res += (cr * (cr + 1)) / 2; cr = 0;
}
}
res += (cr * (cr + 1)) / 2;
cout << res << "\n";
}
}else{
for(int i =0; i < q; i++){
int x; cin >> x;
ll id = upper_bound(a, a + n, x) - a;
ll res = id * (id + 1) / 2;
cout << res << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
212 KB |
Output is correct |
23 |
Correct |
5 ms |
212 KB |
Output is correct |
24 |
Correct |
5 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
1492 KB |
Output is correct |
2 |
Correct |
29 ms |
1732 KB |
Output is correct |
3 |
Correct |
25 ms |
1532 KB |
Output is correct |
4 |
Correct |
28 ms |
1600 KB |
Output is correct |
5 |
Correct |
24 ms |
1524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
3080 KB |
Output is correct |
2 |
Correct |
189 ms |
3080 KB |
Output is correct |
3 |
Correct |
182 ms |
3024 KB |
Output is correct |
4 |
Correct |
182 ms |
3080 KB |
Output is correct |
5 |
Correct |
177 ms |
3028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
188 ms |
3188 KB |
Output is correct |
2 |
Correct |
204 ms |
3276 KB |
Output is correct |
3 |
Correct |
190 ms |
3232 KB |
Output is correct |
4 |
Correct |
234 ms |
3364 KB |
Output is correct |
5 |
Correct |
209 ms |
3328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
24 ms |
1492 KB |
Output is correct |
12 |
Correct |
29 ms |
1732 KB |
Output is correct |
13 |
Correct |
25 ms |
1532 KB |
Output is correct |
14 |
Correct |
28 ms |
1600 KB |
Output is correct |
15 |
Correct |
24 ms |
1524 KB |
Output is correct |
16 |
Correct |
24 ms |
1516 KB |
Output is correct |
17 |
Correct |
29 ms |
1676 KB |
Output is correct |
18 |
Correct |
31 ms |
1696 KB |
Output is correct |
19 |
Correct |
29 ms |
1612 KB |
Output is correct |
20 |
Correct |
28 ms |
1680 KB |
Output is correct |
21 |
Correct |
29 ms |
1508 KB |
Output is correct |
22 |
Correct |
26 ms |
1628 KB |
Output is correct |
23 |
Correct |
26 ms |
1612 KB |
Output is correct |
24 |
Correct |
31 ms |
1628 KB |
Output is correct |
25 |
Correct |
27 ms |
1592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
212 KB |
Output is correct |
23 |
Correct |
5 ms |
212 KB |
Output is correct |
24 |
Correct |
5 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
212 KB |
Output is correct |
26 |
Correct |
24 ms |
1492 KB |
Output is correct |
27 |
Correct |
29 ms |
1732 KB |
Output is correct |
28 |
Correct |
25 ms |
1532 KB |
Output is correct |
29 |
Correct |
28 ms |
1600 KB |
Output is correct |
30 |
Correct |
24 ms |
1524 KB |
Output is correct |
31 |
Correct |
187 ms |
3080 KB |
Output is correct |
32 |
Correct |
189 ms |
3080 KB |
Output is correct |
33 |
Correct |
182 ms |
3024 KB |
Output is correct |
34 |
Correct |
182 ms |
3080 KB |
Output is correct |
35 |
Correct |
177 ms |
3028 KB |
Output is correct |
36 |
Correct |
188 ms |
3188 KB |
Output is correct |
37 |
Correct |
204 ms |
3276 KB |
Output is correct |
38 |
Correct |
190 ms |
3232 KB |
Output is correct |
39 |
Correct |
234 ms |
3364 KB |
Output is correct |
40 |
Correct |
209 ms |
3328 KB |
Output is correct |
41 |
Correct |
24 ms |
1516 KB |
Output is correct |
42 |
Correct |
29 ms |
1676 KB |
Output is correct |
43 |
Correct |
31 ms |
1696 KB |
Output is correct |
44 |
Correct |
29 ms |
1612 KB |
Output is correct |
45 |
Correct |
28 ms |
1680 KB |
Output is correct |
46 |
Correct |
29 ms |
1508 KB |
Output is correct |
47 |
Correct |
26 ms |
1628 KB |
Output is correct |
48 |
Correct |
26 ms |
1612 KB |
Output is correct |
49 |
Correct |
31 ms |
1628 KB |
Output is correct |
50 |
Correct |
27 ms |
1592 KB |
Output is correct |
51 |
Incorrect |
184 ms |
3204 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
212 KB |
Output is correct |
23 |
Correct |
5 ms |
212 KB |
Output is correct |
24 |
Correct |
5 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
212 KB |
Output is correct |
26 |
Correct |
24 ms |
1492 KB |
Output is correct |
27 |
Correct |
29 ms |
1732 KB |
Output is correct |
28 |
Correct |
25 ms |
1532 KB |
Output is correct |
29 |
Correct |
28 ms |
1600 KB |
Output is correct |
30 |
Correct |
24 ms |
1524 KB |
Output is correct |
31 |
Correct |
187 ms |
3080 KB |
Output is correct |
32 |
Correct |
189 ms |
3080 KB |
Output is correct |
33 |
Correct |
182 ms |
3024 KB |
Output is correct |
34 |
Correct |
182 ms |
3080 KB |
Output is correct |
35 |
Correct |
177 ms |
3028 KB |
Output is correct |
36 |
Correct |
188 ms |
3188 KB |
Output is correct |
37 |
Correct |
204 ms |
3276 KB |
Output is correct |
38 |
Correct |
190 ms |
3232 KB |
Output is correct |
39 |
Correct |
234 ms |
3364 KB |
Output is correct |
40 |
Correct |
209 ms |
3328 KB |
Output is correct |
41 |
Correct |
24 ms |
1516 KB |
Output is correct |
42 |
Correct |
29 ms |
1676 KB |
Output is correct |
43 |
Correct |
31 ms |
1696 KB |
Output is correct |
44 |
Correct |
29 ms |
1612 KB |
Output is correct |
45 |
Correct |
28 ms |
1680 KB |
Output is correct |
46 |
Correct |
29 ms |
1508 KB |
Output is correct |
47 |
Correct |
26 ms |
1628 KB |
Output is correct |
48 |
Correct |
26 ms |
1612 KB |
Output is correct |
49 |
Correct |
31 ms |
1628 KB |
Output is correct |
50 |
Correct |
27 ms |
1592 KB |
Output is correct |
51 |
Incorrect |
184 ms |
3204 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |