답안 #1047956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1047956 2024-08-07T18:44:44 Z DeathIsAwe Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
239 ms 38336 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main() {
    int n; cin >> n;
    vector<int> newties(n+1), oldties(n), unsortednew;
    unordered_map<int,ll> ansmap, strange;
    for (int i=0;i<n+1;i++) {
        cin >> newties[i];
    }
    for (int i=0;i<n;i++) {
        cin >> oldties[i];
    }
    unsortednew = newties;


    sort(newties.begin(), newties.end());
    sort(oldties.begin(), oldties.end());
    priority_queue<ll> lol;
    ll ans = 0, dummy;
    for (int i=0;i<n;i++) {
        dummy = max(newties[i+1] - oldties[i], 0);
        if (strange.find(dummy) != strange.end()) {
            strange[dummy] += 1;
        } else {
            strange[dummy] = 1;
            lol.push(dummy);
        }
    }
    ansmap[newties[0]] = lol.top();
    for (int i=0;i<n;i++) {
        dummy = max(newties[i+1] - oldties[i], 0);
        strange[dummy] -= 1;
        dummy = max(newties[i] - oldties[i], 0);
        if (strange.find(dummy) != strange.end()) {
            strange[dummy] += 1;
        } else {
            strange[dummy] = 1;
            lol.push(dummy);
        }
        while (strange[lol.top()] == 0) {
            lol.pop();
        }
        ansmap[newties[i+1]] = lol.top();
    }
    for (int i=0;i<n+1;i++) {
        cout << ansmap[unsortednew[i]] << ' ';
    }
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:22:8: warning: unused variable 'ans' [-Wunused-variable]
   22 |     ll ans = 0, dummy;
      |        ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 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 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 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 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 736 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 1 ms 704 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 448 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 2 ms 604 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 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 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 736 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 1 ms 704 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 448 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 180 ms 29068 KB Output is correct
34 Correct 201 ms 34232 KB Output is correct
35 Correct 170 ms 26724 KB Output is correct
36 Correct 188 ms 33316 KB Output is correct
37 Correct 239 ms 34236 KB Output is correct
38 Correct 216 ms 38336 KB Output is correct
39 Correct 161 ms 17400 KB Output is correct
40 Correct 161 ms 17404 KB Output is correct
41 Correct 148 ms 17688 KB Output is correct
42 Correct 148 ms 17404 KB Output is correct
43 Correct 147 ms 17400 KB Output is correct
44 Correct 135 ms 16152 KB Output is correct
45 Correct 142 ms 16032 KB Output is correct
46 Correct 136 ms 15976 KB Output is correct
47 Correct 106 ms 10652 KB Output is correct
48 Correct 105 ms 10536 KB Output is correct
49 Correct 178 ms 17656 KB Output is correct
50 Correct 149 ms 17656 KB Output is correct
51 Correct 150 ms 17660 KB Output is correct
52 Correct 149 ms 17660 KB Output is correct
53 Correct 151 ms 17764 KB Output is correct