제출 #393591

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

using namespace std;

typedef long long ll;

int n;
pair<int, int> a[200002];
int b[200002];
multiset<int> mst;
int ans[200002];

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++){
        mst.insert(a[i].first - b[i]);
    }
    ans[a[n+1].second] = *mst.rbegin();

    for(int i=n; i>=1; i--){
        mst.erase(mst.find(a[i].first - b[i]));
        mst.insert(a[i+1].first - b[i]);
        ans[a[i].second] = *mst.rbegin();
    }


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

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

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
ho_t1.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         scanf("%d", &a[i].first);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.cpp:19:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |     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...