Submission #890471

# Submission time Handle Problem Language Result Execution time Memory
890471 2023-12-21T09:53:27 Z hafo Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
82 ms 6268 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pa pair<int, int>
#define pall pair<ll, int>
#define fi first
#define se second
#define TASK "test"
#define Size(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;}
template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;}

const int MOD = 1e9 + 7;
const int LOG = 20;
const int maxn = 2e5 + 7;
const ll oo = 1e18 + 69;

int n, b[maxn], res[maxn], suf[maxn];
pa a[maxn];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    cin>>n;
    for(int i = 1; i <= n + 1; i++) {
        cin>>a[i].fi;
        a[i].se = i;
    }
    for(int i = 1; i <= n; i++) cin>>b[i];

    sort(a + 1, a + 1 + n + 1);
    sort(b + 1, b + 1 + n);
    for(int i = n; i >= 1; i--) {
        suf[i] = suf[i + 1];
        maxi(suf[i], max(0, a[i + 1].fi - b[i]));
    }

    res[a[1].se] = suf[1];
    int pre = 0;
    for(int i = 1; i <= n; i++) {
        maxi(pre, max(0, a[i].fi - b[i]));
        res[a[i + 1].se] = max(pre, suf[i + 1]);
    }
    for(int i = 1; i <= n + 1; i++) cout<<res[i]<<" ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 66 ms 5716 KB Output is correct
34 Correct 67 ms 5712 KB Output is correct
35 Correct 64 ms 5712 KB Output is correct
36 Correct 72 ms 6256 KB Output is correct
37 Correct 67 ms 6268 KB Output is correct
38 Correct 67 ms 6224 KB Output is correct
39 Correct 66 ms 5244 KB Output is correct
40 Correct 68 ms 5200 KB Output is correct
41 Correct 65 ms 5384 KB Output is correct
42 Correct 82 ms 5320 KB Output is correct
43 Correct 68 ms 5200 KB Output is correct
44 Correct 75 ms 5088 KB Output is correct
45 Correct 68 ms 4964 KB Output is correct
46 Correct 69 ms 4920 KB Output is correct
47 Correct 70 ms 4728 KB Output is correct
48 Correct 61 ms 4688 KB Output is correct
49 Correct 68 ms 5496 KB Output is correct
50 Correct 67 ms 5460 KB Output is correct
51 Correct 66 ms 5500 KB Output is correct
52 Correct 67 ms 5328 KB Output is correct
53 Correct 67 ms 5496 KB Output is correct