Submission #702473

# Submission time Handle Problem Language Result Execution time Memory
702473 2023-02-24T07:31:43 Z 1075508020060209tc Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
432 ms 23684 KB
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;
int orgar[500005];
int ar[500005];
int br[500005];
int psans[500005];
int sfans[500005];
signed main(){
cin>>n;
for(int i=1;i<=n+1;i++){
    cin>>orgar[i];
    ar[i]=orgar[i];
}
for(int i=1;i<=n;i++){
    cin>>br[i];
}
sort(ar+1,ar+n+1+1);
sort(br+1,br+n+1);
for(int i=1;i<=n;i++){
    psans[i]=max(psans[i-1],ar[i]-br[i]);
}
for(int i=n+1;i>=2;i--){
    sfans[i]=max(sfans[i+1],ar[i]-br[i-1]);
}
map<int,int>mp;
for(int i=1;i<=n+1;i++){
    mp[ar[i]]=max(psans[i-1],sfans[i+1]);
}
for(int i=1;i<=n+1;i++){
    cout<<mp[orgar[i]]<<" ";
}


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 0 ms 308 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 0 ms 308 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 0 ms 312 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 2 ms 456 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 452 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 2 ms 516 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 500 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 0 ms 308 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 0 ms 312 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 2 ms 456 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 452 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 2 ms 516 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 500 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 365 ms 22288 KB Output is correct
34 Correct 432 ms 23172 KB Output is correct
35 Correct 377 ms 22520 KB Output is correct
36 Correct 356 ms 23068 KB Output is correct
37 Correct 374 ms 23684 KB Output is correct
38 Correct 373 ms 23396 KB Output is correct
39 Correct 351 ms 22300 KB Output is correct
40 Correct 376 ms 22264 KB Output is correct
41 Correct 368 ms 22696 KB Output is correct
42 Correct 353 ms 22476 KB Output is correct
43 Correct 350 ms 22420 KB Output is correct
44 Correct 346 ms 21732 KB Output is correct
45 Correct 370 ms 21932 KB Output is correct
46 Correct 347 ms 21724 KB Output is correct
47 Correct 221 ms 12236 KB Output is correct
48 Correct 224 ms 12324 KB Output is correct
49 Correct 366 ms 22936 KB Output is correct
50 Correct 408 ms 23060 KB Output is correct
51 Correct 375 ms 22892 KB Output is correct
52 Correct 362 ms 23008 KB Output is correct
53 Correct 369 ms 22992 KB Output is correct