Submission #687719

# Submission time Handle Problem Language Result Execution time Memory
687719 2023-01-26T21:49:40 Z coldy Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
189 ms 10792 KB
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    pair <int, int> a[n + 1];
    int b[n];
    for(int i = 0; i <= n; i++)cin>>a[i].first, a[i].second = i + 1;
    for(int i = 0; i < n; i++)cin>>b[i];
    sort(a, a + n + 1);
    sort(b, b + n);
    int leftMax[n + 1];
    int rightMax[n + 1];
    int ans[n + 1];
    for(int i = 0; i <= n; i++)ans[i] = (int)1e9;
    for(int i = 0; i <= n; i++)leftMax[i] = 0, rightMax[i] = 0;
    leftMax[0] = (int)0;
    leftMax[1] = max(a[0].first - b[0], 0);
    rightMax[n - 1] = a[n].first - b[n - 1];
    rightMax[n] = (int)0;
    for(int i = 2; i <= n; i++){
        int cur = max(a[i - 1].first - b[i - 1], 0);
        leftMax[i] = max(leftMax[i - 1], cur);
    }
    for(int i = n - 2; i >= 0; i--){
        int cur = max(a[i + 1].first - b[i], 0);
        rightMax[i] = max(rightMax[i + 1], cur);
    }
    for(int i = 0; i <= n; i++){
        //cout<<leftMax[i]<<" "<<rightMax[i]<<endl;
        ans[a[i].second - 1] = max(leftMax[i], rightMax[i]);
    }
    for(int i = 0; i <= n; i++)cout<<ans[i]<<" ";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 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 212 KB Output is correct
3 Correct 0 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 179 ms 9932 KB Output is correct
34 Correct 187 ms 10272 KB Output is correct
35 Correct 180 ms 9948 KB Output is correct
36 Correct 184 ms 10444 KB Output is correct
37 Correct 186 ms 10792 KB Output is correct
38 Correct 184 ms 10700 KB Output is correct
39 Correct 186 ms 9724 KB Output is correct
40 Correct 178 ms 9676 KB Output is correct
41 Correct 180 ms 9804 KB Output is correct
42 Correct 189 ms 9756 KB Output is correct
43 Correct 176 ms 9712 KB Output is correct
44 Correct 174 ms 9292 KB Output is correct
45 Correct 185 ms 9424 KB Output is correct
46 Correct 175 ms 9292 KB Output is correct
47 Correct 180 ms 9408 KB Output is correct
48 Correct 184 ms 9332 KB Output is correct
49 Correct 184 ms 9904 KB Output is correct
50 Correct 183 ms 9932 KB Output is correct
51 Correct 184 ms 9908 KB Output is correct
52 Correct 186 ms 9900 KB Output is correct
53 Correct 183 ms 9904 KB Output is correct