제출 #543657

#제출 시각아이디문제언어결과실행 시간메모리
543657AsymmetryGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
40 ms6984 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; long long t[N]; long long pref_nad[N]; long long suff_nad[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%lld", &t[i]); } for (int i = 2; i <= n; ++i) { pref_nad[i] = pref_nad[i - 1]; if (t[i] <= t[i - 1]) { pref_nad[i] += t[i - 1] - t[i] + 1; } } for (int i = n - 1; i; --i) { suff_nad[i] = suff_nad[i + 1]; if (t[i] <= t[i + 1]) { suff_nad[i] += t[i + 1] - t[i] + 1; } } long long odp = 1e18; for (int i = 1; i <= n; ++i) { //~ debug(i, pref_nad[i], suff_nad[i]); odp = min(odp, max(pref_nad[i], suff_nad[i])); } printf("%lld\n", odp); return 0; }

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

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