답안 #647318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647318 2022-10-02T07:44:11 Z Astrayt Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
115 ms 10048 KB
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second

void solve(){
    int n, t = 0; cin >> n;
    vector<pii> a(n + 1, pii(0, 0));
    vector<int> b(n), ns(n), s(n);
    for(auto &[x, y]:a) cin >> x, y = t++;
    for(auto &x:b) cin >> x;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for(int i = 0; i < n; ++i){
        ns[i] = max(0ll, a[i].ff - b[i]);
        s[i] = max(0ll, a[i + 1].ff - b[i]);
    }
    for(int i = 1; i < n; ++i){
        int j = n - i - 1;
        ns[i] = max(ns[i - 1], ns[i]);
        s[j] = max(s[j], s[j + 1]);
    }
    for(int i = 0; i <= n; ++i){
        int ans = 0;
        if(i != 0) ans = max(ans, ns[i - 1]);
        if(i != n) ans = max(ans, s[i]);
        a[i].ff = ans;
    }
    sort(a.begin(), a.end(), [](pii a, pii b){return a.ss < b.ss;});
    for(int i = 0; i <= n; ++i){
        cout << a[i].ff << " \n"[i == n];
    }
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 95 ms 9176 KB Output is correct
34 Correct 100 ms 9620 KB Output is correct
35 Correct 102 ms 9244 KB Output is correct
36 Correct 100 ms 9768 KB Output is correct
37 Correct 103 ms 10048 KB Output is correct
38 Correct 106 ms 9948 KB Output is correct
39 Correct 113 ms 8948 KB Output is correct
40 Correct 94 ms 8932 KB Output is correct
41 Correct 110 ms 9136 KB Output is correct
42 Correct 113 ms 9116 KB Output is correct
43 Correct 101 ms 8944 KB Output is correct
44 Correct 93 ms 8660 KB Output is correct
45 Correct 94 ms 8744 KB Output is correct
46 Correct 105 ms 8548 KB Output is correct
47 Correct 99 ms 8668 KB Output is correct
48 Correct 88 ms 8664 KB Output is correct
49 Correct 97 ms 9304 KB Output is correct
50 Correct 98 ms 9296 KB Output is correct
51 Correct 115 ms 9312 KB Output is correct
52 Correct 110 ms 9420 KB Output is correct
53 Correct 97 ms 9300 KB Output is correct