Submission #774423

# Submission time Handle Problem Language Result Execution time Memory
774423 2023-07-05T17:43:36 Z kirakaminski968 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
82 ms 11612 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int N; cin >> N;
    vector<pair<int,int>> arr(N+1); vector<int> help(N+1);
    for(int i = 0;i<=N;++i){
        cin >> arr[i].first;
        arr[i].second = i;
    }
    sort(arr.begin(),arr.end());
    for(int i = 0;i<=N;++i) help[arr[i].second] = i;
    vector<int> brr(N);
    for(int i = 0;i<N;++i){
        cin >> brr[i];
    }
    sort(brr.begin(),brr.end());
    vector<int> pref(N),suf(N);
    for(int i = 0;i<N;++i){
        if(i == 0){
            pref[i] = max(arr[i].first-brr[i],0);
        }
        else{
            pref[i] = max(max(arr[i].first-brr[i],0),pref[i-1]);
        }
        //cout << pref[i] << " ";
    }
    //cout << "\n";
    for(int i = N-1;i>=0;--i){
        if(i == N-1){
            suf[i] = max(arr[i+1].first-brr[i],0);
        }
        else{
            suf[i] = max(max(arr[i+1].first-brr[i],0),suf[i+1]);
        }
        //cout << suf[i] << " ";
    }
    //cout << "\n";
    vector<int> ans(N+1);
    for(int i = 0;i<=N;++i){
        if(i == 0) ans[arr[i].second] = suf[i];
        else if(i == N) ans[arr[i].second] = pref[N-1];
        else{
            ans[arr[i].second] = max(suf[i],pref[i-1]);
        }
    }
    for(int i = 0;i<=N;++i) cout << ans[i] << " ";
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 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 1 ms 288 KB Output is correct
20 Correct 1 ms 336 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 332 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 332 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 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 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 1 ms 288 KB Output is correct
20 Correct 1 ms 336 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 332 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 332 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 2 ms 340 KB Output is correct
33 Correct 68 ms 10700 KB Output is correct
34 Correct 72 ms 11072 KB Output is correct
35 Correct 69 ms 10756 KB Output is correct
36 Correct 69 ms 11168 KB Output is correct
37 Correct 74 ms 11612 KB Output is correct
38 Correct 73 ms 11420 KB Output is correct
39 Correct 69 ms 10444 KB Output is correct
40 Correct 69 ms 10508 KB Output is correct
41 Correct 82 ms 10536 KB Output is correct
42 Correct 70 ms 10544 KB Output is correct
43 Correct 73 ms 10516 KB Output is correct
44 Correct 67 ms 10064 KB Output is correct
45 Correct 69 ms 10188 KB Output is correct
46 Correct 67 ms 10096 KB Output is correct
47 Correct 69 ms 10212 KB Output is correct
48 Correct 65 ms 10208 KB Output is correct
49 Correct 72 ms 10852 KB Output is correct
50 Correct 72 ms 10860 KB Output is correct
51 Correct 71 ms 10740 KB Output is correct
52 Correct 71 ms 10828 KB Output is correct
53 Correct 74 ms 10864 KB Output is correct