제출 #586144

#제출 시각아이디문제언어결과실행 시간메모리
586144hibikiGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++11
100 / 100
31 ms6928 KiB
#include<bits/stdc++.h> using namespace std; int n; long long a[200005]; long long dpl[200005], dpr[200005]; int main() { scanf("%d",&n); for(int i = 0; i < n; i++) scanf("%lld",&a[i]); for(int i = 1; i < n; i++) dpl[i] = dpl[i - 1] + max(a[i - 1] - a[i] + 1, 0ll); for(int i = n - 2; i >= 0; i--) dpr[i] = dpr[i + 1] + max(a[i + 1] - a[i] + 1, 0ll); long long ans = min(dpl[n - 1], dpr[0]); for(int i = 0; i < n; i++) { // printf("%lld %lld\n", dpl[i], dpr[i]); ans = min(ans, max(dpl[i], dpr[i + 1]) + max(a[i + 1] - a[i] + dpr[i + 1] - dpl[i] + 1, 0ll)); } printf("%lld\n",ans); return 0; }

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

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