제출 #391239

#제출 시각아이디문제언어결과실행 시간메모리
391239keta_tsimakuridzeGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
95 ms6920 KiB
#include<bits/stdc++.h> #define f first #define int long long #define s second using namespace std; const int N=2e5+5,mod=1e9+7,Inf=1e15; int t,n,ans,pref[N],suf[N],a[N]; string s; main(){ // t=1; cin >> n; ans = Inf; for(int i=1;i<=n;i++){ cin>>a[i]; if(i-1) pref[i] = pref[i-1] + max(0ll,a[i-1]-a[i]+1); } for(int i=n;i>=1;i--){ if(i!=n) suf[i] = suf[i+1] + max(0ll,a[i+1]-a[i]+1); ans = min(ans,max(suf[i],pref[i])); } cout<<ans; }

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

Main.cpp:9:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 |  main(){
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...