제출 #756790

#제출 시각아이디문제언어결과실행 시간메모리
756790peraGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
88 ms7064 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 30000 + 1; main(){ int n;cin >> n; vector<int> a(n + 1) , p(n + 1) , s(n + 2) , A(n + 1); for(int i = 1;i <= n;i ++){ cin >> a[i]; A[i] = a[i]; } for(int i = 2;i <= n;i ++){ p[i] = p[i - 1]; if(a[i] <= a[i - 1]) p[i] += a[i - 1] - a[i] + 1; } for(int i = n - 1;i >= 1;i --){ s[i] = s[i + 1]; if(a[i] <= a[i + 1]) s[i] += a[i + 1] - a[i] + 1; } int ans = LLONG_MAX; for(int i = 1;i <= n;i ++){ ans = min(ans , max(p[i] , s[i])); } cout << ans << endl; }

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

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