제출 #212508

#제출 시각아이디문제언어결과실행 시간메모리
212508DystoriaXJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
150 ms9336 KiB
#include <bits/stdc++.h>

using namespace std;

int n;
pair<int, int> a[200010];
int b[200010];
int ans[200010];

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

    for(int i = 1; i <= n + 1; i++) scanf("%d", &a[i].first), a[i].second = i;
    for(int i = 1; i <= n; i++) scanf("%d", &b[i]);

    sort(a + 1, a + n + 2);
    sort(b + 1, b + n + 1);

    for(int i = 1; i <= n; i++){
        ans[a[n + 1].second] = max(ans[a[n + 1].second], a[i].first - b[i]);
    }

    for(int i = n; i; i--){
        ans[a[i].second] = max(ans[a[i + 1].second], a[i + 1].first - b[i]);
    }

    for(int i = 1; i <= n + 1; i++){
        printf("%d ", ans[i]);
    }
    
    printf("\n");

    return 0;
}

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

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
ho_t1.cpp:13:61: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n + 1; i++) scanf("%d", &a[i].first), a[i].second = i;
                                     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
ho_t1.cpp:14:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
                                 ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...