Submission #1083971

# Submission time Handle Problem Language Result Execution time Memory
1083971 2024-09-04T17:01:24 Z ZeroCool Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
175 ms 28496 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ar array

const int LOG = 20;
const int MOD = 1e9 + 7;
const int INF = 1e18;

const int N = 3e5 + 20;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,avx,bmi,bmi2")

int a[N], A[N], B[N], pref[N], suff[N];
int n;


signed main(){ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i = 1;i <= n + 1;i++)cin>>a[i], A[i] = a[i];
    for(int i = 1;i <= n;i++)cin>>B[i];
    sort(A + 1, A + n + 2);
    sort(B + 1, B + n + 1);
    //assert(0);
    for(int i = 1;i <= n;i++)pref[i] = max(pref[i - 1], A[i] - B[i]);
    for(int i = n + 1;i > 1;i--)suff[i] = max(suff[i + 1], A[i] - B[i - 1]);
    map<int,int> ans;
    for(int i =1;i <= n + 1;i++)ans[A[i]] = max(pref[i - 1], suff[i + 1]);
    for(int i = 1 ;i <= n + 1;i++)cout<<ans[a[i]]<<" ";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 1 ms 6652 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 2 ms 6748 KB Output is correct
25 Correct 2 ms 6748 KB Output is correct
26 Correct 2 ms 6748 KB Output is correct
27 Correct 2 ms 6744 KB Output is correct
28 Correct 2 ms 6648 KB Output is correct
29 Correct 1 ms 6748 KB Output is correct
30 Correct 2 ms 6748 KB Output is correct
31 Correct 2 ms 6748 KB Output is correct
32 Correct 2 ms 6652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 1 ms 6652 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 2 ms 6748 KB Output is correct
25 Correct 2 ms 6748 KB Output is correct
26 Correct 2 ms 6748 KB Output is correct
27 Correct 2 ms 6744 KB Output is correct
28 Correct 2 ms 6648 KB Output is correct
29 Correct 1 ms 6748 KB Output is correct
30 Correct 2 ms 6748 KB Output is correct
31 Correct 2 ms 6748 KB Output is correct
32 Correct 2 ms 6652 KB Output is correct
33 Correct 161 ms 27000 KB Output is correct
34 Correct 173 ms 27960 KB Output is correct
35 Correct 166 ms 27220 KB Output is correct
36 Correct 156 ms 27700 KB Output is correct
37 Correct 170 ms 28496 KB Output is correct
38 Correct 169 ms 28244 KB Output is correct
39 Correct 168 ms 27216 KB Output is correct
40 Correct 164 ms 26940 KB Output is correct
41 Correct 164 ms 27220 KB Output is correct
42 Correct 168 ms 27472 KB Output is correct
43 Correct 158 ms 26960 KB Output is correct
44 Correct 170 ms 26336 KB Output is correct
45 Correct 174 ms 26644 KB Output is correct
46 Correct 150 ms 26456 KB Output is correct
47 Correct 97 ms 16976 KB Output is correct
48 Correct 103 ms 16976 KB Output is correct
49 Correct 170 ms 27732 KB Output is correct
50 Correct 161 ms 27728 KB Output is correct
51 Correct 175 ms 27628 KB Output is correct
52 Correct 168 ms 27728 KB Output is correct
53 Correct 159 ms 27696 KB Output is correct