제출 #224014

#제출 시각아이디문제언어결과실행 시간메모리
224014tqbfjotldJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
135 ms8292 KiB
#include <bits/stdc++.h> using namespace std; int ans[200005]; vector<pair<int,int> > a; vector<int> b; int n; int pre[200005]; int suf[200005]; int main(){ scanf("%d",&n); for (int x = 0; x<n+1; x++){ int c; scanf("%d",&c); a.push_back({c,x}); } for (int x = 0; x<n; x++){ int c; scanf("%d",&c); b.push_back(c); } sort(a.begin(),a.end()); sort(b.begin(),b.end()); int t = 0; for (int x = 0; x<n; x++){ t = max(t,a[x].first-b[x]); pre[x] = t; } t = 0; for (int x = n-1; x>=0; x--){ t = max(t,a[x+1].first-b[x]); suf[x] = t; } for (int x = 0; x<=n; x++){ if (x==0) ans[a[x].second] = suf[0]; else if (x==n) ans[a[x].second] = pre[x-1]; else ans[a[x].second] = max(pre[x-1],suf[x]); } for (int x = 0; x<=n; x++){ printf("%d ",ans[x]); } }

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

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