제출 #545009

#제출 시각아이디문제언어결과실행 시간메모리
545009AsymmetryJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
98 ms10824 KiB
//Autor: Bartłomiej Czarkowski #include <bits/stdc++.h> using namespace std; #ifdef DEBUG template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';} #define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n' #else #define debug(...) {} #endif const int N = 201000; int n; int B[N]; int odp[N]; int pref[N]; int suff[N]; pair<int, int> sr[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n + 1; ++i) { scanf("%d", &sr[i].first); sr[i].second = i; } for (int i = 1; i <= n; ++i) { scanf("%d", &B[i]); } sort(sr + 1, sr + 2 + n); sort(B + 1, B + 1 + n); for (int i = 1; i <= n; ++i) { pref[i] = max(pref[i - 1], max(0, sr[i].first - B[i])); } for (int i = n + 1; i > 1; --i) { suff[i] = max(suff[i + 1], max(0, sr[i].first - B[i - 1])); } for (int i = 1; i <= n + 1; ++i) { odp[sr[i].second] = max(pref[i - 1], suff[i + 1]); } for (int i = 1; i <= n + 1; ++i) { printf("%d ", odp[i]); } printf("\n"); return 0; }

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

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
ho_t1.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d", &sr[i].first);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d", &B[i]);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...