제출 #224020

#제출 시각아이디문제언어결과실행 시간메모리
224020cheehengJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
315 ms14840 KiB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;

ii C[200005];
int B[200005];
int ans[200005];

// 3 4 6 7
// 2 4 6

int main(){
    int N;
    scanf("%d", &N);

    for(int i = 0; i <= N; i ++){
        int x;
        scanf("%d", &x);
        C[i] = ii(x, i);
    }

    sort(C, C+(N+1));

    for(int i = 0; i < N; i ++){
        scanf("%d", &B[i]);
    }
    sort(B, B+N);

    multiset<int> oddities;
    for(int i = 0; i < N; i ++){
        oddities.insert(max(C[i].first-B[i], 0));
    }
    ans[C[N].second] = *(--oddities.end());

    for(int i = N-1; i >= 0; i --){
        oddities.erase(max(C[i].first-B[i], 0));
        oddities.insert(max(C[i+1].first-B[i], 0));
        ans[C[i].second] = *(--oddities.end());
    }

    for(int i = 0; i <= N; i ++){
        printf("%d ", ans[i]);
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
ho_t1.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
ho_t1.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &B[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...