Submission #735307

# Submission time Handle Problem Language Result Execution time Memory
735307 2023-05-03T23:59:31 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
336 ms 35772 KB
#include <bits/stdc++.h>
#define B begin()
#define E end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define sts stable_sort
using namespace std;

const int MAXN = 1e6 + 4;
const int MOD = 1e9 + 7;

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

    int n; cin >> n;
    vector<ll> v(n + 1);
    vector<ll> asd(n + 1);
    vector<ll> b(n);

    for(int i = 0; i <= n; i++){
        cin >> v[i];
        asd[i] = v[i];
    }
    sts(v.B, v.E);

    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    sts(b.B, b.E);
    map<ll, ll> m;
    map<ll, ll> mmax;

    ll maxdesp = 0;
    for(int i = n; i > 0; i--){
        maxdesp = max(maxdesp, (v[i] - b[i - 1]));
//        cout << maxdesp << " " << i << "\n";
        mmax[i] = maxdesp;
    }

    ll maxant = 0;
    for(int i = 0; i <= n; i++){
        if(i < n){
            maxant = max(maxant, (v[i] - b[i]));
        }
//        cout << maxant << "\n";
        m[v[i]] = max(maxant, mmax[i + 1]);
    }

    for(int i = 0; i <= n; i++){
        cout << m[asd[i]] << " ";
    }cout << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 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 320 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 320 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 316 KB Output is correct
3 Correct 1 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 320 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 2 ms 464 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 524 KB Output is correct
18 Correct 2 ms 596 KB Output is correct
19 Correct 2 ms 588 KB Output is correct
20 Correct 2 ms 596 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 2 ms 596 KB Output is correct
23 Correct 2 ms 588 KB Output is correct
24 Correct 2 ms 516 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 2 ms 596 KB Output is correct
27 Correct 3 ms 532 KB Output is correct
28 Correct 2 ms 520 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 2 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 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 320 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 2 ms 464 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 524 KB Output is correct
18 Correct 2 ms 596 KB Output is correct
19 Correct 2 ms 588 KB Output is correct
20 Correct 2 ms 596 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 2 ms 596 KB Output is correct
23 Correct 2 ms 588 KB Output is correct
24 Correct 2 ms 516 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 2 ms 596 KB Output is correct
27 Correct 3 ms 532 KB Output is correct
28 Correct 2 ms 520 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 2 ms 584 KB Output is correct
33 Correct 285 ms 33824 KB Output is correct
34 Correct 313 ms 35256 KB Output is correct
35 Correct 332 ms 34004 KB Output is correct
36 Correct 312 ms 34660 KB Output is correct
37 Correct 305 ms 35772 KB Output is correct
38 Correct 319 ms 35336 KB Output is correct
39 Correct 301 ms 34148 KB Output is correct
40 Correct 299 ms 33924 KB Output is correct
41 Correct 306 ms 34328 KB Output is correct
42 Correct 295 ms 34212 KB Output is correct
43 Correct 302 ms 33920 KB Output is correct
44 Correct 286 ms 33340 KB Output is correct
45 Correct 300 ms 33492 KB Output is correct
46 Correct 298 ms 33288 KB Output is correct
47 Correct 177 ms 24452 KB Output is correct
48 Correct 179 ms 24564 KB Output is correct
49 Correct 318 ms 35088 KB Output is correct
50 Correct 334 ms 35080 KB Output is correct
51 Correct 298 ms 35028 KB Output is correct
52 Correct 320 ms 35016 KB Output is correct
53 Correct 336 ms 35256 KB Output is correct