답안 #854242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854242 2023-09-26T13:03:59 Z LeVanThuc Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
73 ms 14080 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
    if(x<y)
    {
        x=y;
        return 1;
    }
    return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
    if(x>y)
    {
        x=y;
        return 1;
    }
    return 0;
}
void online()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef thuc
    freopen("input.INP","r",stdin);
    freopen("output.OUT","w",stdout);
#endif
}
const ll N=2e5+10,inf=1e18;
pll a[N];
ll b[N],f[N],n,ans[N];
int main()
{
    online();
    cin>>n;
    for(int i=1;i<=n+1;i++)
    {
        cin>>a[i].fi;
        a[i].se=i;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    for(int i=n+1;i>=2;i--)
    {
        f[i]=a[i].fi-b[i-1];
        f[i]=max(f[i],f[i+1]);
    }
    ans[a[1].se]=f[2];
    ll cr=0;
    for(int i=1;i<=n;i++)
    {
        maximize(cr,a[i].fi-b[i]);
        ans[a[i+1].se]=max(cr,f[i+2]);
    }
    for(int i=1;i<=n+1;i++)
    {
        cout<<ans[i]<<' ';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6744 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 2 ms 6488 KB Output is correct
24 Correct 2 ms 6488 KB Output is correct
25 Correct 2 ms 6488 KB Output is correct
26 Correct 2 ms 6488 KB Output is correct
27 Correct 2 ms 6488 KB Output is correct
28 Correct 2 ms 6488 KB Output is correct
29 Correct 2 ms 6944 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 1 ms 6492 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6744 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 2 ms 6488 KB Output is correct
24 Correct 2 ms 6488 KB Output is correct
25 Correct 2 ms 6488 KB Output is correct
26 Correct 2 ms 6488 KB Output is correct
27 Correct 2 ms 6488 KB Output is correct
28 Correct 2 ms 6488 KB Output is correct
29 Correct 2 ms 6944 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 1 ms 6492 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
33 Correct 71 ms 13392 KB Output is correct
34 Correct 71 ms 13588 KB Output is correct
35 Correct 69 ms 13320 KB Output is correct
36 Correct 69 ms 13772 KB Output is correct
37 Correct 70 ms 14080 KB Output is correct
38 Correct 70 ms 13908 KB Output is correct
39 Correct 68 ms 12880 KB Output is correct
40 Correct 68 ms 12964 KB Output is correct
41 Correct 69 ms 13116 KB Output is correct
42 Correct 68 ms 13068 KB Output is correct
43 Correct 67 ms 12860 KB Output is correct
44 Correct 71 ms 12484 KB Output is correct
45 Correct 70 ms 12680 KB Output is correct
46 Correct 67 ms 12672 KB Output is correct
47 Correct 65 ms 12624 KB Output is correct
48 Correct 63 ms 12500 KB Output is correct
49 Correct 70 ms 13136 KB Output is correct
50 Correct 73 ms 13244 KB Output is correct
51 Correct 71 ms 13184 KB Output is correct
52 Correct 71 ms 13136 KB Output is correct
53 Correct 70 ms 13136 KB Output is correct