제출 #397663

#제출 시각아이디문제언어결과실행 시간메모리
397663ChrisTGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
38 ms6212 KiB
#include <bits/stdc++.h> using namespace std; const int MN = 1e6 + 5; int main () { int n; scanf ("%d",&n); vector<long long> pre(n+1), suf(n+2); vector<int> a(n+1); long long ret = 1e18; for (int i = 1; i <= n; i++) { scanf ("%d",&a[i]); if (i > 1) pre[i] = pre[i-1] + max(0,a[i-1] - a[i] + 1); } for (int i = n; i >= 1; i--) { if (i < n) suf[i] = suf[i+1] + max(0,a[i+1] - a[i] + 1); ret = min(ret,max(pre[i],suf[i])); } printf ("%lld\n",ret); return 0; }

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

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