제출 #530318

#제출 시각아이디문제언어결과실행 시간메모리
530318soondro2266Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
40 / 100
1075 ms5356 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector<int> arr; int n; int check(int idx){ vector<int> akr = arr; int a = 0,b = 0; for(int i = 1; i <= idx; i++){ if(akr[i-1] >= akr[i]){ a += akr[i-1]+1-akr[i]; } } for(int i = n-1; i > idx; i--){ if(akr[i-1] <= akr[i]){ b += akr[i]+1-akr[i-1]; } } return max(a,b); } signed main(){ cin >> n; for(int i = 0,tmp; i < n; i++){ cin >> tmp; arr.push_back(tmp); } int ans = 1e18; for(int i = 0; i < n;i++){ ans = min(ans,check(i)); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...