답안 #486055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486055 2021-11-10T13:34:01 Z DJ035 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 332 KB
# pragma GCC optimize ("O3")
# pragma GCC optimize ("Ofast")
# pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define MEM 222222
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define pf push_front
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz size()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
typedef pair<pi, pi> pii;
const ll MOD = 1e18;
const ll INF = 2e9+7;
const long double Pi = 3.141592;
ll gp(ll a, ll b){
    return ((a*b)%MOD+MOD)%MOD;
}
ll t,n;
ll b[MEM];
pi a[MEM];
ll ans[MEM], c1[MEM], c2[MEM];
signed main(){
    sanic; cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i=1; i<=n+1; i++){
        cin >> a[i].x;
        a[i].y = 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=1; i<=n; i++){
        c1[i] = a[i].x-b[i];
        c2[i] = a[i+1].x-b[i];
        //cout << c1[i] << ' ' << c2[i] << '\n';
    }
    for(int i=1; i<=n; i++)
        c1[i] = max(c1[i], c1[i-1]);
    for(int i=n; i>0; i--)
        c2[i] = max(c2[i], c2[i+1]);
    for(int i=1; i<=n+1; i++){
        ll j = a[i].y;
        ans[j] = max(max(c1[j-1], c2[j]), 0LL);
        // << j << ' ' << ans[j] << '\n';
    }
    for(int i=1; i<=n+1; i++)
        cout << ans[i] << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -