답안 #210783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210783 2020-03-18T10:54:15 Z aryan12 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
131 ms 10104 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        long long n;
        cin >> n;
        long long a[n + 1];
        vector<pair<long long, long long> >b(n + 2); //wearing and index
        for(long long i = 0; i <= n; i++) {
            cin >> b[i].first; //to wear
            b[i].second = i;
        }
        for(long long i = 1; i <= n; i++) {
            cin >> a[i]; //already wearing
        }
        sort(a + 1, a + 1 + n);
        a[0] = -1;
        sort(b.begin(), b.end() - 1);
        /*for(long long i = 0; i <= n; i++) {
            cout << a[i] << " " << b[i].first << endl;
        }*/
        long long c[n + 1], ans = 0, d = 0;
        long long suf[n + 1];
        suf[n] = b[n].first - a[n];
        for(long long i = n - 1; i > 0; i--) {
            suf[i] = max(suf[i + 1], b[i].first - a[i]);
        }
        for(long long i = 0; i <= n; i++) {
            if(i != 0) {
                d = max(d, b[i - 1].first - a[i]);
            }
            //managers necklace;
            if(i != n)
                ans = max(d, suf[i + 1]);
            else
                ans = d;
            c[b[i].second] = ans;
        }
        for(long long i = 0; i <= n; i++) {
            cout << c[i] << " ";
        }
        cout << endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 380 KB Output is correct
16 Correct 5 ms 372 KB Output is correct
17 Correct 6 ms 508 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 7 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 7 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 380 KB Output is correct
16 Correct 5 ms 372 KB Output is correct
17 Correct 6 ms 508 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 7 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 7 ms 504 KB Output is correct
33 Correct 119 ms 9336 KB Output is correct
34 Correct 125 ms 9720 KB Output is correct
35 Correct 115 ms 9464 KB Output is correct
36 Correct 114 ms 9848 KB Output is correct
37 Correct 118 ms 10104 KB Output is correct
38 Correct 121 ms 9976 KB Output is correct
39 Correct 115 ms 9080 KB Output is correct
40 Correct 117 ms 9120 KB Output is correct
41 Correct 117 ms 9208 KB Output is correct
42 Correct 115 ms 9200 KB Output is correct
43 Correct 117 ms 9208 KB Output is correct
44 Correct 114 ms 8804 KB Output is correct
45 Correct 114 ms 8824 KB Output is correct
46 Correct 131 ms 8764 KB Output is correct
47 Correct 110 ms 8696 KB Output is correct
48 Correct 110 ms 8696 KB Output is correct
49 Correct 118 ms 9336 KB Output is correct
50 Correct 121 ms 9336 KB Output is correct
51 Correct 120 ms 9336 KB Output is correct
52 Correct 117 ms 9320 KB Output is correct
53 Correct 117 ms 9300 KB Output is correct