답안 #924495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924495 2024-02-09T05:46:06 Z mocha Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 6492 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mx = 2e5+1;

int n;
pair<int,int> a[mx];
int b[mx];
int d[mx], rd[mx];
int ans[mx];

signed main() {
    cin.tie(0);ios::sync_with_stdio(0);
    cin >> n;
    for (int i=0;i<=n;i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i=0;i<n;i++) {
        cin >> b[i];
    }
    sort(a,a+n+1);
    sort(b,b+n);
    d[0] = max(a[0].first-b[0],0LL);
    for (int i=1;i<n;i++) {
        d[i] = max(d[i-1],a[i].first-b[i]);
    }
    rd[n-1] = a[n].first - b[n-1];
    rd[n-1] = max(d[n-1],0LL);
    for (int i=n-2;i>=0;i--) {
        rd[i] = max(rd[i+1],a[i+1].first-b[i]);
    }
    ans[a[0].second] = rd[0];
    ans[a[n].second] = d[n-1];
    // for (int i=0;i<n;i++) {
    //     cout << d[i] << " " << rd[i] << "\n";
    // }
    for (int i=1;i<n;i++) {
        ans[a[i].second] = max(d[i-1],rd[i]);
    }
    for (int i=0;i<=n;i++) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Incorrect 1 ms 6492 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Incorrect 1 ms 6492 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Incorrect 1 ms 6492 KB Output isn't correct
7 Halted 0 ms 0 KB -