Submission #919748

# Submission time Handle Problem Language Result Execution time Memory
919748 2024-02-01T15:18:13 Z ByeWorld Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
0 ms 600 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#define bupol __builtin_popcount
#define int long long 
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
const int MAXN = 1e5+10;
const int MAXK = 2010;
const int LOG = 20;
const int MOD = 1e9+7;
const int SQRT = 520;
const int INF = 1e9+10;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;

int n;
int a[MAXN], b[MAXN], ans[MAXN];
int pr[MAXN], su[MAXN];
vector <pii> vec;

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i=0; i<=n; i++){
        cin >> a[i]; vec.pb({a[i], i});
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i<n; i++) cin >> b[i];
    sort(b+0, b+n);

    for(int i=0; i<=n-1; i++){
        if(i!=0) pr[i] = pr[i-1];
        pr[i] = max(pr[i], vec[i].fi-b[i]);
        //cout << i << ' ' << pr[i] << " p\n";
    }
    for(int i=n; i>=1; i--){
        su[i] = su[i+1];
        su[i] = max(su[i], vec[i].fi-b[i-1]);
        //cout << i << ' ' << su[i] << " p\n";
    }

    for(int i=0; i<=n; i++){ // kalo i ilang
        int num = 0;
        if(i!=0) num = pr[i-1];
        num = max(num, su[i+1]);
        ans[i] = num;
    }

    for(int i=0; i<n+1; i++) cout << ans[i] << " \n"[i==n];
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -