답안 #349919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349919 2021-01-18T17:12:27 Z shivensinha4 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
327 ms 21996 KB
#include "bits/stdc++.h"
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'


int main() {
#ifdef mlocal
    freopen("test.in", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    vector<ll> b(n);
    vector<pair<ll, int>> a(n+1);
    for_(i, 0, n+1) {
        cin >> a[i].first;
        a[i].second = i;
    }

    for_(i, 0, n) cin >> b[i];
    sort(a.begin(), a.end()); sort(b.begin(), b.end());

    multiset<ll> s;
    vector<ll> ans(n+1);
//    for_(i, 0, n+1) cout << a[i].first << " " << a[i].second << endl;
    for_(i, 1, n+1) {
        s.insert(a[i].first-b[i-1]);
    }

//    for (auto j: s) cout << j << " ";
//    cout << endl;
    ans[a[0].second] = *s.rbegin();
    for_(i, 1,n+1) {
        s.erase(s.find(a[i].first-b[i-1]));
        s.insert(a[i-1].first-b[i-1]);
//        for (auto j: s) cout << j << " ";
//        cout << endl;
        ans[a[i].second] = *s.rbegin();
    }

    for_(i, 0, n+1) cout << max(0LL, ans[i]) << " ";
    cout << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 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 1 ms 364 KB Output is correct
6 Correct 1 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 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 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 1 ms 364 KB Output is correct
6 Correct 1 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 1 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 384 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 532 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 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 1 ms 364 KB Output is correct
6 Correct 1 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 1 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 384 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 532 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
33 Correct 242 ms 20716 KB Output is correct
34 Correct 235 ms 21384 KB Output is correct
35 Correct 222 ms 20716 KB Output is correct
36 Correct 225 ms 21228 KB Output is correct
37 Correct 235 ms 21996 KB Output is correct
38 Correct 222 ms 21620 KB Output is correct
39 Correct 304 ms 20588 KB Output is correct
40 Correct 305 ms 20460 KB Output is correct
41 Correct 303 ms 20716 KB Output is correct
42 Correct 297 ms 20588 KB Output is correct
43 Correct 298 ms 20588 KB Output is correct
44 Correct 205 ms 19820 KB Output is correct
45 Correct 210 ms 20076 KB Output is correct
46 Correct 202 ms 19948 KB Output is correct
47 Correct 177 ms 20460 KB Output is correct
48 Correct 179 ms 20460 KB Output is correct
49 Correct 316 ms 21116 KB Output is correct
50 Correct 327 ms 21100 KB Output is correct
51 Correct 314 ms 21100 KB Output is correct
52 Correct 319 ms 21228 KB Output is correct
53 Correct 318 ms 21100 KB Output is correct