답안 #1114827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114827 2024-11-19T16:37:04 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin>>n;
    vector<pair<long long, long long>> neckties(n+1);
    vector<long long> employees(n);
    for (long long i=0;i<n+1;i++){
        cin>>neckties[i].first;
        neckties[i].second=i;
    }
    for (long long i=0;i<n;i++) cin>>employees[i];
    sort(neckties.begin(), neckties.end(), greater<pair<long long, long long>>());
    sort(employees.begin(), employees.end(), greater<long long>());
    vector<long long> noSkipOut(n+1);
    noSkipOut[0]=neckties[0].first-employees[0];
    noSkipOut[n]=-1;
    for (long long i=1;i<n;i++){
        noSkipOut[i]=max(noSkipOut[i-1], neckties[i].first-employees[i]);
    }
    vector<long long> skipOut(n+1);
    skipOut[0]=-1;
    skipOut[n]=neckties[n].first-employees[n-1];
    for (long long i=n;i>0;i--){
        skipOut[i]=max(skipOut[i+1], neckties[i].first-employees[i-1]);
    }
    vector<long long> finalOut(n+1);
    finalOut[neckties[0].second]=skipOut[1];
    finalOut[neckties[n].second]=noSkipOut[n-1];
    for (long long i=0;i<n+1;i++){
        finalOut[neckties[i].second]=max(noSkipOut[i-1], skipOut[i+1]);
    }
    for (long long x:finalOut) cout<<x<<" ";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Halted 0 ms 0 KB -