제출 #415296

#제출 시각아이디문제언어결과실행 시간메모리
415296NintsiChkhaidzeGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
35 ms7000 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define s second #define f first #define int ll using namespace std; const int N = 200005; ll a[N],pref[N],suff[N]; vector <int> v; main (){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n; cin>>n; for (int i=1;i<=n;i++) cin>>a[i]; ll ans=1e18; for (int i=1;i<=n;i++) pref[i] = pref[i - 1] + max((ll)0,a[i - 1] - a[i] + 1); for (int i = n; i >= 1; i--) suff[i] = suff[i + 1] + max((ll)0,a[i + 1] - a[i] + 1); for (int i=1;i<=n;i++) ans = min(ans,max(pref[i],suff[i])); cout<<ans; }

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

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