Submission #922888

# Submission time Handle Problem Language Result Execution time Memory
922888 2024-02-06T08:53:42 Z dimashhh Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
103 ms 10836 KB
#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 12, MOD = 1e9 + 7;

typedef long long ll;

int n,a[N],b[N],p[N],pref[N],sf[N],res[N];
void test(){
    cin >> n;
    for(int i = 1;i <= n + 1;i++){
        cin >> a[i];
        p[i] = i;
    }
    sort(p + 1,p + n + 2,[&](int x,int y){
        return a[x] < a[y];
    });
    sort(a + 1,a + n +2 );
    for(int i = 1;i <= n;i++){
        cin >> b[i];
    }
    sort(b + 1,b + n + 1);
    for(int i = 1;i <= n;i++){
        pref[i] = max(pref[i - 1],max(0,a[i] - b[i]));
    }
    for(int i = n;i >= 1;i--){
        sf[i] = max(sf[i + 1],a[i + 1] - b[i]);
    }
    for(int i = 1;i <= n + 1;i++){
        res[p[i]] =max(pref[i - 1],sf[i]);
    }
    for(int i = 1;i <= n + 1;i++){
        cout << res[i] << ' ';
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int T = 1;
//    cin >> T;
    while (T--)
        test();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2512 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2512 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2524 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2520 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2512 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2524 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2520 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 86 ms 10072 KB Output is correct
34 Correct 103 ms 10556 KB Output is correct
35 Correct 86 ms 10064 KB Output is correct
36 Correct 86 ms 10576 KB Output is correct
37 Correct 88 ms 10832 KB Output is correct
38 Correct 93 ms 10836 KB Output is correct
39 Correct 88 ms 9816 KB Output is correct
40 Correct 87 ms 9796 KB Output is correct
41 Correct 85 ms 9788 KB Output is correct
42 Correct 86 ms 9908 KB Output is correct
43 Correct 92 ms 9780 KB Output is correct
44 Correct 83 ms 9516 KB Output is correct
45 Correct 83 ms 9552 KB Output is correct
46 Correct 83 ms 9532 KB Output is correct
47 Correct 64 ms 9552 KB Output is correct
48 Correct 64 ms 9484 KB Output is correct
49 Correct 88 ms 10064 KB Output is correct
50 Correct 101 ms 10184 KB Output is correct
51 Correct 88 ms 10068 KB Output is correct
52 Correct 87 ms 10180 KB Output is correct
53 Correct 87 ms 10068 KB Output is correct