답안 #481708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481708 2021-10-21T12:11:42 Z Lobo Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
93 ms 10760 KB
#include <bits/stdc++.h>
 
using namespace std;

const long long INFll = (long long) 1e18 + 10;
const int INFii = (int) 1e9 + 10;
typedef long long ll;
typedef int ii;
typedef long double dbl;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 220000

ii n, ans[maxn], b[maxn], ps[maxn], sf[maxn];
pair<ii,ii> a[maxn];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);

    //freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);

    cin >> n;

    for(ii i = 1; i <= n+1; i++) {
        cin >> a[i].fr;
        a[i].sc = i;
    }

    for(ii i = 1; i <= n; i++)
        cin >> b[i];
    
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    

    ps[0] = 0;
    for(ii i = 1; i <= n; i++) {
        ps[i] = ps[i-1];
        ps[i] = max(ps[i],a[i].fr-b[i]);
    }

    sf[n+1] = 0;
    for(ii i = n; i >= 1; i--) {
        sf[i] = sf[i+1];
        sf[i] = max(sf[i],a[i+1].fr-b[i]);
    }

    for(ii i = 1; i <= n+1; i++) {
        ans[a[i].sc] = max(ps[i-1],sf[i]);
    }

    for(ii i = 1; i <= n+1; i++) {
        cout << ans[i] << " ";
    }

    cout << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 3 ms 328 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 3 ms 328 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 80 ms 9996 KB Output is correct
34 Correct 91 ms 10308 KB Output is correct
35 Correct 82 ms 9960 KB Output is correct
36 Correct 93 ms 10520 KB Output is correct
37 Correct 82 ms 10760 KB Output is correct
38 Correct 83 ms 10692 KB Output is correct
39 Correct 83 ms 9692 KB Output is correct
40 Correct 82 ms 9652 KB Output is correct
41 Correct 81 ms 9796 KB Output is correct
42 Correct 90 ms 9944 KB Output is correct
43 Correct 79 ms 9668 KB Output is correct
44 Correct 76 ms 9284 KB Output is correct
45 Correct 77 ms 9440 KB Output is correct
46 Correct 78 ms 9304 KB Output is correct
47 Correct 77 ms 9444 KB Output is correct
48 Correct 74 ms 9440 KB Output is correct
49 Correct 82 ms 9956 KB Output is correct
50 Correct 91 ms 10056 KB Output is correct
51 Correct 82 ms 10032 KB Output is correct
52 Correct 85 ms 10120 KB Output is correct
53 Correct 82 ms 10052 KB Output is correct