# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334109 |
2020-12-08T10:50:17 Z |
aryan12 |
Pilot (NOI19_pilot) |
C++17 |
|
239 ms |
3308 KB |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
long long a[N];
long long n, q;
//for 78 points
void Solve1() {
for(long long i = 1; i <= q; i++) {
long long x;
cin >> x;
long long ans = 0, cnt = 0;
for(long long j = 1; j <= n; j++) {
if(a[j] <= x) {
cnt++;
ans++;
}
else {
ans += (cnt * (cnt - 1)) / 2;
cnt = 0;
}
}
ans += (cnt * (cnt - 1)) / 2;
cout << ans << endl;
}
}
void Solve2() {
for(long long i = 1; i <= q; i++) {
long long x;
cin >> x;
long long l = 1, r = n;
long long mid, ans = 0;
while(l <= r) {
mid = (l + r) / 2;
if(a[mid] <= x) {
ans = mid;
l = mid + 1;
}
else {
r = mid - 1;
}
}
cout << ans * (ans - 1) / 2 << endl;
}
}
void Solve() {
cin >> n >> q;
for(long long i = 1; i <= n; i++) {
cin >> a[i];
}
if(n * q <= 1e6) {
Solve1();
}
else {
Solve2();
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
Solve();
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 |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
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 |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 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 |
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 |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 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 |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
372 KB |
Output is correct |
17 |
Correct |
2 ms |
372 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 |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 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 |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
372 KB |
Output is correct |
17 |
Correct |
2 ms |
372 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 |
4 ms |
364 KB |
Output is correct |
22 |
Correct |
5 ms |
364 KB |
Output is correct |
23 |
Correct |
4 ms |
364 KB |
Output is correct |
24 |
Correct |
5 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1644 KB |
Output is correct |
2 |
Correct |
10 ms |
1772 KB |
Output is correct |
3 |
Correct |
9 ms |
1644 KB |
Output is correct |
4 |
Correct |
9 ms |
1644 KB |
Output is correct |
5 |
Correct |
9 ms |
1644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
237 ms |
3212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
239 ms |
3308 KB |
Output isn't correct |
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 |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
10 ms |
1644 KB |
Output is correct |
12 |
Correct |
10 ms |
1772 KB |
Output is correct |
13 |
Correct |
9 ms |
1644 KB |
Output is correct |
14 |
Correct |
9 ms |
1644 KB |
Output is correct |
15 |
Correct |
9 ms |
1644 KB |
Output is correct |
16 |
Correct |
9 ms |
1644 KB |
Output is correct |
17 |
Correct |
11 ms |
1772 KB |
Output is correct |
18 |
Correct |
11 ms |
1772 KB |
Output is correct |
19 |
Correct |
10 ms |
1596 KB |
Output is correct |
20 |
Correct |
10 ms |
1772 KB |
Output is correct |
21 |
Correct |
9 ms |
1792 KB |
Output is correct |
22 |
Correct |
10 ms |
1644 KB |
Output is correct |
23 |
Correct |
12 ms |
1644 KB |
Output is correct |
24 |
Correct |
10 ms |
1644 KB |
Output is correct |
25 |
Correct |
10 ms |
1644 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 |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 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 |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
372 KB |
Output is correct |
17 |
Correct |
2 ms |
372 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 |
4 ms |
364 KB |
Output is correct |
22 |
Correct |
5 ms |
364 KB |
Output is correct |
23 |
Correct |
4 ms |
364 KB |
Output is correct |
24 |
Correct |
5 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
10 ms |
1644 KB |
Output is correct |
27 |
Correct |
10 ms |
1772 KB |
Output is correct |
28 |
Correct |
9 ms |
1644 KB |
Output is correct |
29 |
Correct |
9 ms |
1644 KB |
Output is correct |
30 |
Correct |
9 ms |
1644 KB |
Output is correct |
31 |
Incorrect |
237 ms |
3212 KB |
Output isn't correct |
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 |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 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 |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
372 KB |
Output is correct |
17 |
Correct |
2 ms |
372 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 |
4 ms |
364 KB |
Output is correct |
22 |
Correct |
5 ms |
364 KB |
Output is correct |
23 |
Correct |
4 ms |
364 KB |
Output is correct |
24 |
Correct |
5 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
10 ms |
1644 KB |
Output is correct |
27 |
Correct |
10 ms |
1772 KB |
Output is correct |
28 |
Correct |
9 ms |
1644 KB |
Output is correct |
29 |
Correct |
9 ms |
1644 KB |
Output is correct |
30 |
Correct |
9 ms |
1644 KB |
Output is correct |
31 |
Incorrect |
237 ms |
3212 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |