답안 #787303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787303 2023-07-19T04:23:25 Z winter0101 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
88 ms 10796 KB
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
#define pil pair<int,long long>
pii a[200009];
int b[200009];
int p[200009],s[200009];
int ans[200009];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("temp.INP","r",stdin);
    //freopen("temp.OUT","w",stdout);
    int n;
    cin>>n;
    for1(i,1,n+1){
    cin>>a[i].fi;
    a[i].se=i;
    }
    for1(i,1,n)cin>>b[i];
    sort(a+1,a+1+n+1);
    sort(b+1,b+1+n);
    for1(i,1,n){
    p[i]=max(p[i-1],max(a[i].fi-b[i],0));
    }
    for2(i,n+1,2){
    s[i]=max(s[i+1],max(a[i].fi-b[i-1],0));
    }
    for1(i,1,n+1){
    ans[a[i].se]=max(p[i-1],s[i+1]);
    }
    for1(i,1,n+1)cout<<ans[i]<<" ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 1 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 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 432 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 372 KB Output is correct
29 Correct 1 ms 376 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 1 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 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 432 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 372 KB Output is correct
29 Correct 1 ms 376 KB Output is correct
30 Correct 1 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 72 ms 9992 KB Output is correct
34 Correct 69 ms 10396 KB Output is correct
35 Correct 67 ms 10060 KB Output is correct
36 Correct 74 ms 10456 KB Output is correct
37 Correct 73 ms 10796 KB Output is correct
38 Correct 88 ms 10704 KB Output is correct
39 Correct 71 ms 9800 KB Output is correct
40 Correct 69 ms 9672 KB Output is correct
41 Correct 69 ms 9872 KB Output is correct
42 Correct 70 ms 9764 KB Output is correct
43 Correct 71 ms 9688 KB Output is correct
44 Correct 78 ms 9272 KB Output is correct
45 Correct 69 ms 9356 KB Output is correct
46 Correct 76 ms 9360 KB Output is correct
47 Correct 64 ms 9384 KB Output is correct
48 Correct 78 ms 9388 KB Output is correct
49 Correct 82 ms 9988 KB Output is correct
50 Correct 72 ms 9992 KB Output is correct
51 Correct 77 ms 9988 KB Output is correct
52 Correct 70 ms 9980 KB Output is correct
53 Correct 75 ms 10040 KB Output is correct