Submission #937812

# Submission time Handle Problem Language Result Execution time Memory
937812 2024-03-04T14:04:20 Z Andrey Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
75 ms 15640 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,a;
    cin >> n;
    vector<long long> ans(n+1);
    vector<pair<long long,long long>> haha(n+1);
    vector<long long> bruh(n);
    for(long long i = 0; i <= n; i++) {
        cin >> a;
        haha[i] = {a,i};
    }
    for(long long i = 0; i < n; i++) {
        cin >> bruh[i];
    }
    sort(haha.begin(),haha.end());
    sort(bruh.begin(),bruh.end());
    vector<long long> pr(n+1);
    vector<long long> su(n+1);
    for(long long i = 1; i <= n; i++) {
        pr[i] = max(haha[i-1].first-bruh[i-1],0LL);
        pr[i] = max(pr[i],pr[i-1]);
    }
    for(long long i = n-1; i >= 0; i--) {
        su[i] = max(haha[i+1].first-bruh[i],0LL);
        su[i] = max(su[i],su[i+1]);
    }
    for(long long i = 0; i < n+1; i++) {
        ans[haha[i].second] = max(pr[i],su[i]);
    }
    for(long long i = 0; i < n+1; i++) {
        cout << ans[i] << " ";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 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 348 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 344 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 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 348 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 344 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 348 KB Output is correct
33 Correct 69 ms 14444 KB Output is correct
34 Correct 73 ms 14964 KB Output is correct
35 Correct 71 ms 14612 KB Output is correct
36 Correct 72 ms 15148 KB Output is correct
37 Correct 73 ms 15640 KB Output is correct
38 Correct 72 ms 15432 KB Output is correct
39 Correct 70 ms 14416 KB Output is correct
40 Correct 74 ms 14348 KB Output is correct
41 Correct 71 ms 14372 KB Output is correct
42 Correct 70 ms 14432 KB Output is correct
43 Correct 72 ms 14452 KB Output is correct
44 Correct 68 ms 13764 KB Output is correct
45 Correct 69 ms 14016 KB Output is correct
46 Correct 68 ms 13908 KB Output is correct
47 Correct 67 ms 14160 KB Output is correct
48 Correct 66 ms 14160 KB Output is correct
49 Correct 72 ms 14676 KB Output is correct
50 Correct 75 ms 14672 KB Output is correct
51 Correct 72 ms 14756 KB Output is correct
52 Correct 71 ms 14644 KB Output is correct
53 Correct 74 ms 14716 KB Output is correct