답안 #787310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787310 2023-07-19T04:48:02 Z Sandarach151 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
2 ms 212 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    pair<int, int> arr[n+1];
    int ties[n];
    for(int i=0; i<=n; i++){
        cin >> arr[i].first;
        arr[i].second = i;
    }
    for(int i=0; i<n; i++){
        cin >> ties[i];
    }
    sort(arr, arr+n+1);
    sort(ties, ties+n);
    int ans[n+1];
    multiset<int, greater<int>> st;
    for(int i=1; i<=n; i++){
        st.insert(abs(ties[i-1]-arr[i].first));
        ans[0]=*st.begin();
    }
    for(int taken = 1; taken<=n; taken++){
        st.erase(st.find(abs(arr[taken].first-ties[taken-1])));
        st.insert(abs(arr[taken-1].first-ties[taken-1]));
        ans[taken]=*st.begin();
    }
    int finans[n+1];
    for(int i=0; i<=n; i++){
        finans[arr[i].second]=ans[i];
    }
    for(int i=0; i<=n; i++){
        cout << finans[i] << ' ';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -