답안 #334113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334113 2020-12-08T10:55:08 Z aryan12 Pilot (NOI19_pilot) C++17
78 / 100
261 ms 3564 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 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 0 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 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 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 0 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 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 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 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 0 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 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 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 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 0 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 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 1 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 4 ms 364 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 5 ms 492 KB Output is correct
24 Correct 5 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1132 KB Output is correct
2 Correct 10 ms 1132 KB Output is correct
3 Correct 12 ms 1132 KB Output is correct
4 Correct 9 ms 1004 KB Output is correct
5 Correct 11 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 2028 KB Output is correct
2 Correct 249 ms 3308 KB Output is correct
3 Correct 248 ms 3180 KB Output is correct
4 Correct 239 ms 3308 KB Output is correct
5 Correct 241 ms 3180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 241 ms 2028 KB Output is correct
2 Correct 255 ms 3376 KB Output is correct
3 Correct 259 ms 3436 KB Output is correct
4 Correct 240 ms 3396 KB Output is correct
5 Correct 261 ms 3564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 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 0 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 0 ms 364 KB Output is correct
11 Correct 9 ms 1132 KB Output is correct
12 Correct 10 ms 1132 KB Output is correct
13 Correct 12 ms 1132 KB Output is correct
14 Correct 9 ms 1004 KB Output is correct
15 Correct 11 ms 1004 KB Output is correct
16 Correct 9 ms 1004 KB Output is correct
17 Correct 14 ms 1132 KB Output is correct
18 Correct 10 ms 1132 KB Output is correct
19 Correct 9 ms 1004 KB Output is correct
20 Correct 10 ms 1132 KB Output is correct
21 Correct 9 ms 1004 KB Output is correct
22 Correct 10 ms 1004 KB Output is correct
23 Correct 10 ms 1132 KB Output is correct
24 Correct 9 ms 1004 KB Output is correct
25 Correct 10 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 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 0 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 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 1 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 4 ms 364 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 5 ms 492 KB Output is correct
24 Correct 5 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 9 ms 1132 KB Output is correct
27 Correct 10 ms 1132 KB Output is correct
28 Correct 12 ms 1132 KB Output is correct
29 Correct 9 ms 1004 KB Output is correct
30 Correct 11 ms 1004 KB Output is correct
31 Correct 235 ms 2028 KB Output is correct
32 Correct 249 ms 3308 KB Output is correct
33 Correct 248 ms 3180 KB Output is correct
34 Correct 239 ms 3308 KB Output is correct
35 Correct 241 ms 3180 KB Output is correct
36 Correct 241 ms 2028 KB Output is correct
37 Correct 255 ms 3376 KB Output is correct
38 Correct 259 ms 3436 KB Output is correct
39 Correct 240 ms 3396 KB Output is correct
40 Correct 261 ms 3564 KB Output is correct
41 Correct 9 ms 1004 KB Output is correct
42 Correct 14 ms 1132 KB Output is correct
43 Correct 10 ms 1132 KB Output is correct
44 Correct 9 ms 1004 KB Output is correct
45 Correct 10 ms 1132 KB Output is correct
46 Correct 9 ms 1004 KB Output is correct
47 Correct 10 ms 1004 KB Output is correct
48 Correct 10 ms 1132 KB Output is correct
49 Correct 9 ms 1004 KB Output is correct
50 Correct 10 ms 1132 KB Output is correct
51 Incorrect 246 ms 3312 KB Output isn't correct
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 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 0 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 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 1 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 4 ms 364 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 5 ms 492 KB Output is correct
24 Correct 5 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 9 ms 1132 KB Output is correct
27 Correct 10 ms 1132 KB Output is correct
28 Correct 12 ms 1132 KB Output is correct
29 Correct 9 ms 1004 KB Output is correct
30 Correct 11 ms 1004 KB Output is correct
31 Correct 235 ms 2028 KB Output is correct
32 Correct 249 ms 3308 KB Output is correct
33 Correct 248 ms 3180 KB Output is correct
34 Correct 239 ms 3308 KB Output is correct
35 Correct 241 ms 3180 KB Output is correct
36 Correct 241 ms 2028 KB Output is correct
37 Correct 255 ms 3376 KB Output is correct
38 Correct 259 ms 3436 KB Output is correct
39 Correct 240 ms 3396 KB Output is correct
40 Correct 261 ms 3564 KB Output is correct
41 Correct 9 ms 1004 KB Output is correct
42 Correct 14 ms 1132 KB Output is correct
43 Correct 10 ms 1132 KB Output is correct
44 Correct 9 ms 1004 KB Output is correct
45 Correct 10 ms 1132 KB Output is correct
46 Correct 9 ms 1004 KB Output is correct
47 Correct 10 ms 1004 KB Output is correct
48 Correct 10 ms 1132 KB Output is correct
49 Correct 9 ms 1004 KB Output is correct
50 Correct 10 ms 1132 KB Output is correct
51 Incorrect 246 ms 3312 KB Output isn't correct
52 Halted 0 ms 0 KB -