답안 #866111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866111 2023-10-25T12:34:53 Z raphaelp Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
215 ms 10188 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> ties;
    vector<int> start(N);
    for (int i = 0; i <= N; i++)
    {
        int temp;
        cin >> temp;
        ties.push_back({temp, i});
    }
    for (int i = 0; i < N; i++)
    {
        cin >> start[i];
    }
    sort(start.begin(), start.end());
    sort(ties.begin(), ties.end());
    vector<int> ans(N + 1);
    deque<pair<int, int>> Q;
    for (int i = 1; i <= N; i++)
    {
        while (!Q.empty() && Q.back().first < max(ties[i].first - start[i - 1], 0))
            Q.pop_back();
        Q.push_back({max(ties[i].first - start[i - 1], 0), i - 1});
    }
    ans[ties[0].second] = Q.front().first;
    for (int i = 0; i < N; i++)
    {
        while (!Q.empty() && Q.front().second <= i)
            Q.pop_front();
        while (!Q.empty() && Q.back().first < max(ties[i].first - start[i], 0))
            Q.pop_back();
        Q.push_back({max(ties[i].first - start[i], 0), N + 10});
        ans[ties[i + 1].second] = Q.front().first;
    }
    for (int i = 0; i <= N; i++)
    {
        cout << ans[i] << ' ';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 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 412 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 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 412 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 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 444 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 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 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 500 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 2 ms 444 KB Output is correct
32 Correct 2 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 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 412 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 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 444 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 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 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 500 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 2 ms 444 KB Output is correct
32 Correct 2 ms 352 KB Output is correct
33 Correct 172 ms 8876 KB Output is correct
34 Correct 174 ms 8956 KB Output is correct
35 Correct 168 ms 8828 KB Output is correct
36 Correct 175 ms 8948 KB Output is correct
37 Correct 186 ms 9200 KB Output is correct
38 Correct 174 ms 9152 KB Output is correct
39 Correct 169 ms 9936 KB Output is correct
40 Correct 168 ms 9808 KB Output is correct
41 Correct 176 ms 10188 KB Output is correct
42 Correct 190 ms 9996 KB Output is correct
43 Correct 177 ms 9808 KB Output is correct
44 Correct 165 ms 9404 KB Output is correct
45 Correct 165 ms 9668 KB Output is correct
46 Correct 164 ms 9408 KB Output is correct
47 Correct 168 ms 8644 KB Output is correct
48 Correct 188 ms 9412 KB Output is correct
49 Correct 178 ms 10016 KB Output is correct
50 Correct 215 ms 10168 KB Output is correct
51 Correct 173 ms 10180 KB Output is correct
52 Correct 180 ms 10076 KB Output is correct
53 Correct 182 ms 10040 KB Output is correct