Submission #385235

# Submission time Handle Problem Language Result Execution time Memory
385235 2021-04-03T19:21:28 Z Aryan_Raina Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
119 ms 15512 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double
#define ar array

const int INF = 1e15;
const int MOD = 1e9+7;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin>>n;
    vector<ar<int,2>> a(n+1);
    vector<int> b(n);
    for (int i = 0; i <= n; i++) {
        cin>>a[i][0]; a[i][1] = i;
    }
    for (int &i : b) cin>>i;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int pf[n], sf[n];
    pf[0] = a[0][0]-b[0];
    for (int i = 1; i < n; i++) pf[i] = max(pf[i-1], a[i][0]-b[i]);
    sf[n-1] = a[n][0]-b[n-1];
    for (int i = n-2; i >= 0; --i) sf[i] = max(sf[i+1], a[i+1][0]-b[i]);
    vector<int> ans(n+1);
    ans[a[0][1]] = sf[0];
    for (int i = 1; i < n; i++) {
        ans[a[i][1]] = max(sf[i], pf[i-1]);
    }
    ans[a[n][1]] = pf[n-1];
    for (int i : ans) cout<<i<<" ";
}  
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 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 384 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 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 384 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 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 2 ms 420 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 500 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 492 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 512 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 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 384 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 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 2 ms 420 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 500 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 492 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 512 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 106 ms 14444 KB Output is correct
34 Correct 113 ms 15084 KB Output is correct
35 Correct 108 ms 14700 KB Output is correct
36 Correct 110 ms 15084 KB Output is correct
37 Correct 116 ms 15512 KB Output is correct
38 Correct 113 ms 15432 KB Output is correct
39 Correct 108 ms 14444 KB Output is correct
40 Correct 109 ms 14444 KB Output is correct
41 Correct 109 ms 14444 KB Output is correct
42 Correct 119 ms 14468 KB Output is correct
43 Correct 110 ms 14316 KB Output is correct
44 Correct 105 ms 13804 KB Output is correct
45 Correct 110 ms 13988 KB Output is correct
46 Correct 113 ms 13804 KB Output is correct
47 Correct 117 ms 14188 KB Output is correct
48 Correct 105 ms 14316 KB Output is correct
49 Correct 111 ms 14956 KB Output is correct
50 Correct 111 ms 14828 KB Output is correct
51 Correct 110 ms 14956 KB Output is correct
52 Correct 111 ms 14828 KB Output is correct
53 Correct 110 ms 14828 KB Output is correct