Submission #922751

# Submission time Handle Problem Language Result Execution time Memory
922751 2024-02-06T05:34:15 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
93 ms 7012 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 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 2392 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 2396 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 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 2392 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 2396 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 2392 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
15 Correct 1 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 2396 KB Output is correct
21 Correct 2 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2512 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 2392 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 2396 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 2392 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
15 Correct 1 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 2396 KB Output is correct
21 Correct 2 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2512 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 83 ms 6448 KB Output is correct
34 Correct 90 ms 6480 KB Output is correct
35 Correct 91 ms 6484 KB Output is correct
36 Correct 90 ms 6980 KB Output is correct
37 Correct 88 ms 7012 KB Output is correct
38 Correct 88 ms 6988 KB Output is correct
39 Correct 89 ms 6236 KB Output is correct
40 Correct 85 ms 5972 KB Output is correct
41 Correct 89 ms 6220 KB Output is correct
42 Correct 84 ms 6236 KB Output is correct
43 Correct 85 ms 5968 KB Output is correct
44 Correct 82 ms 5684 KB Output is correct
45 Correct 85 ms 5948 KB Output is correct
46 Correct 84 ms 5924 KB Output is correct
47 Correct 64 ms 5480 KB Output is correct
48 Correct 62 ms 5476 KB Output is correct
49 Correct 87 ms 6248 KB Output is correct
50 Correct 93 ms 6236 KB Output is correct
51 Correct 88 ms 6132 KB Output is correct
52 Correct 92 ms 6236 KB Output is correct
53 Correct 91 ms 6232 KB Output is correct