제출 #585899

#제출 시각아이디문제언어결과실행 시간메모리
585899krit3379Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; #define N 200005 int a[N],dp1[N],dp2[N],ans=2e9; int main(){ int n,i,ma; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%d",&a[i]); for(i=2;i<=n;i++)dp1[i]+=dp1[i-1]+max(a[i-1]-a[i]+1,0); for(i=n-1;i>0;i--)dp2[i]+=dp2[i+1]+max(a[i+1]-a[i]+1,0); ans=min(dp1[n],dp2[1]); for(i=1;i<n;i++)ans=min(ans,dp1[i]+dp2[i+1]+(a[i]+dp1[i]==a[i+1]+dp2[i])); printf("%d",ans); return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:8:13: warning: unused variable 'ma' [-Wunused-variable]
    8 |     int n,i,ma;
      |             ^~
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
Main.cpp:10:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(i=1;i<=n;i++)scanf("%d",&a[i]);
      |                      ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...