답안 #207541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207541 2020-03-07T21:54:59 Z fishy15 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
318 ms 17248 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>

#define ll long long
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 200000

using namespace std;

int n;
vector<pair<ll, int>> a;
vector<ll> b;
multiset<ll> cur;
int ans[MAXN];

int main() {
    cin.tie(0)->sync_with_stdio(0);

    cin >> n;

    for (int i = 0; i <= n; i++) {
        ll x; cin >> x;
        a.push_back({x, i});
    }

    for (int i = 0; i < n; i++) {
        ll x; cin >> x;
        b.push_back(x);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    for (int i = 0; i < n; i++) {
        cur.insert(a[i].first - b[i]);
    }

    ans[a[n].second] = *cur.rbegin();

    for (int i = n - 1; i >= 0; i--) {
        cur.erase(cur.find(a[i].first - b[i]));
        cur.insert(a[i + 1].first - b[i]);
        ans[a[i].second] = *cur.rbegin();
    }

    for (int i = 0; i <= n; i++) {
        cout << ans[i] << ' ';
    } cout << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 428 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 7 ms 504 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 428 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 7 ms 504 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
33 Correct 242 ms 16096 KB Output is correct
34 Correct 265 ms 16736 KB Output is correct
35 Correct 237 ms 16224 KB Output is correct
36 Correct 253 ms 16608 KB Output is correct
37 Correct 253 ms 17248 KB Output is correct
38 Correct 243 ms 16992 KB Output is correct
39 Correct 295 ms 15968 KB Output is correct
40 Correct 301 ms 15840 KB Output is correct
41 Correct 289 ms 16096 KB Output is correct
42 Correct 298 ms 15968 KB Output is correct
43 Correct 308 ms 16132 KB Output is correct
44 Correct 269 ms 15456 KB Output is correct
45 Correct 281 ms 15716 KB Output is correct
46 Correct 277 ms 15460 KB Output is correct
47 Correct 201 ms 15972 KB Output is correct
48 Correct 201 ms 15840 KB Output is correct
49 Correct 316 ms 16480 KB Output is correct
50 Correct 314 ms 16480 KB Output is correct
51 Correct 313 ms 16480 KB Output is correct
52 Correct 318 ms 16496 KB Output is correct
53 Correct 317 ms 16480 KB Output is correct