제출 #251887

#제출 시각아이디문제언어결과실행 시간메모리
251887ivandasfsJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
143 ms10872 KiB
#include <bits/stdc++.h> using namespace std; #define x first #define y second #define mp make_pair #define pb push_back typedef long long ll; const ll MOD = 1e9+7; const ll INF = 1e9+5; pair <int, int> a[200005]; int b[200005]; int pref[200005]; int suff[200005]; int sol[200005]; int main() { int n; scanf("%d", &n); for (int i=1 ; i<=n+1 ; i++) { scanf("%d", &a[i].x); a[i].y = i; } sort(a+1, a+n+2); for (int i=1 ; i<=n ; i++) { scanf("%d", b+i); } sort(b+1, b+n+1); for (int i=1 ; i<=n ; i++) { pref[i] = max(pref[i-1], max(a[i].x-b[i], 0)); } for (int i=n+1 ; i>=2 ; i--) { suff[i] = max(suff[i+1], max(a[i].x-b[i-1], 0)); } for (int i=1 ; i<=n+1 ; i++) { sol[a[i].y] = max(pref[i-1], suff[i+1]); } for (int i=1 ; i<=n+1 ; i++) { printf("%d ", sol[i]); } printf("\n"); return 0; }

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

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