답안 #1026984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026984 2024-07-18T16:29:10 Z ricardsjansons Pilot (NOI19_pilot) C++14
89 / 100
1000 ms 70204 KB
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    long long n, q;
    cin >> n >> q;

    vector<pair<long long, long long>> h(n + 1);
    for (long long i = 1; i <= n; i++) {
        cin >> h[i].first;
        h[i].second = i;
    }
    sort(h.begin(), h.end());
    h.push_back({1e6 + 1, n + 1});

    vector<pair<long long, long long>> y(q);
    for (long long i = 0; i < q; i++) {
        cin >> y[i].first;
        y[i].second = i;
    }
    sort(y.begin(), y.end());

    vector<long long> l(n + 2);
    vector<long long> r(n + 2);
    vector<long long> res(q);
    long long flights = 0;
    long long j = 0;
    for (long long i = 1; i <= n; i++) {
        while (j < q && h[i].first > y[j].first) {
            res[y[j].second] = flights;
            j++;
        }

        long long index = h[i].second;

        l[index] = l[index - 1] + 1;
        r[index] = r[index + 1] + 1;

        if (r[index] > 1) {
            l[index + r[index] - 1] += l[index];
        }
        if (l[index] > 1) {
            r[index - l[index] + 1] += r[index];
        }

        flights += l[index] * r[index];
    }
    while (j < q) {
        res[y[j].second] = flights;
        j++;
    }

    for (long long f : res) {
        cout << f << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4516 KB Output is correct
2 Correct 27 ms 4700 KB Output is correct
3 Correct 23 ms 3260 KB Output is correct
4 Correct 24 ms 3164 KB Output is correct
5 Correct 26 ms 3252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 6296 KB Output is correct
2 Correct 143 ms 7552 KB Output is correct
3 Correct 142 ms 6436 KB Output is correct
4 Correct 140 ms 7536 KB Output is correct
5 Correct 133 ms 6320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 7804 KB Output is correct
2 Correct 155 ms 7596 KB Output is correct
3 Correct 139 ms 6344 KB Output is correct
4 Correct 133 ms 7196 KB Output is correct
5 Correct 145 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 24 ms 4516 KB Output is correct
12 Correct 27 ms 4700 KB Output is correct
13 Correct 23 ms 3260 KB Output is correct
14 Correct 24 ms 3164 KB Output is correct
15 Correct 26 ms 3252 KB Output is correct
16 Correct 23 ms 4184 KB Output is correct
17 Correct 31 ms 3424 KB Output is correct
18 Correct 26 ms 4544 KB Output is correct
19 Correct 23 ms 3248 KB Output is correct
20 Correct 25 ms 4512 KB Output is correct
21 Correct 22 ms 3264 KB Output is correct
22 Correct 24 ms 3352 KB Output is correct
23 Correct 26 ms 4440 KB Output is correct
24 Correct 24 ms 4544 KB Output is correct
25 Correct 24 ms 4532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 24 ms 4516 KB Output is correct
27 Correct 27 ms 4700 KB Output is correct
28 Correct 23 ms 3260 KB Output is correct
29 Correct 24 ms 3164 KB Output is correct
30 Correct 26 ms 3252 KB Output is correct
31 Correct 132 ms 6296 KB Output is correct
32 Correct 143 ms 7552 KB Output is correct
33 Correct 142 ms 6436 KB Output is correct
34 Correct 140 ms 7536 KB Output is correct
35 Correct 133 ms 6320 KB Output is correct
36 Correct 135 ms 7804 KB Output is correct
37 Correct 155 ms 7596 KB Output is correct
38 Correct 139 ms 6344 KB Output is correct
39 Correct 133 ms 7196 KB Output is correct
40 Correct 145 ms 7772 KB Output is correct
41 Correct 23 ms 4184 KB Output is correct
42 Correct 31 ms 3424 KB Output is correct
43 Correct 26 ms 4544 KB Output is correct
44 Correct 23 ms 3248 KB Output is correct
45 Correct 25 ms 4512 KB Output is correct
46 Correct 22 ms 3264 KB Output is correct
47 Correct 24 ms 3352 KB Output is correct
48 Correct 26 ms 4440 KB Output is correct
49 Correct 24 ms 4544 KB Output is correct
50 Correct 24 ms 4532 KB Output is correct
51 Correct 144 ms 7600 KB Output is correct
52 Correct 146 ms 6288 KB Output is correct
53 Correct 140 ms 7616 KB Output is correct
54 Correct 147 ms 6140 KB Output is correct
55 Correct 134 ms 6328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 24 ms 4516 KB Output is correct
27 Correct 27 ms 4700 KB Output is correct
28 Correct 23 ms 3260 KB Output is correct
29 Correct 24 ms 3164 KB Output is correct
30 Correct 26 ms 3252 KB Output is correct
31 Correct 132 ms 6296 KB Output is correct
32 Correct 143 ms 7552 KB Output is correct
33 Correct 142 ms 6436 KB Output is correct
34 Correct 140 ms 7536 KB Output is correct
35 Correct 133 ms 6320 KB Output is correct
36 Correct 135 ms 7804 KB Output is correct
37 Correct 155 ms 7596 KB Output is correct
38 Correct 139 ms 6344 KB Output is correct
39 Correct 133 ms 7196 KB Output is correct
40 Correct 145 ms 7772 KB Output is correct
41 Correct 23 ms 4184 KB Output is correct
42 Correct 31 ms 3424 KB Output is correct
43 Correct 26 ms 4544 KB Output is correct
44 Correct 23 ms 3248 KB Output is correct
45 Correct 25 ms 4512 KB Output is correct
46 Correct 22 ms 3264 KB Output is correct
47 Correct 24 ms 3352 KB Output is correct
48 Correct 26 ms 4440 KB Output is correct
49 Correct 24 ms 4544 KB Output is correct
50 Correct 24 ms 4532 KB Output is correct
51 Correct 144 ms 7600 KB Output is correct
52 Correct 146 ms 6288 KB Output is correct
53 Correct 140 ms 7616 KB Output is correct
54 Correct 147 ms 6140 KB Output is correct
55 Correct 134 ms 6328 KB Output is correct
56 Execution timed out 1062 ms 70204 KB Time limit exceeded
57 Halted 0 ms 0 KB -