제출 #1001542

#제출 시각아이디문제언어결과실행 시간메모리
1001542walizamaneeGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
66 ms7076 KiB
#include<bits/stdc++.h> using namespace std; int aa; long long a[200001] , one[200001] , two[200001] , ans ; int main() { cin >> aa; for( int z = 0; z < aa; z++ ) cin >> a[z]; for( int z = 1; z < aa; z++ ) one[z] = one[z - 1] + max( (long long)0 , ( a[z - 1] - a[z] ) + 1 ); for( int z = aa - 2; z >= 0; z-- ) two[z] = two[z + 1] + max( (long long)0 , (a[z + 1] - a[z]) + 1 ); ans = 100000000000000000; for( int z = 0; z < aa; z++ ) ans = min( ans , max( one[z] , two[z] ) ); cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...