# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
532476 | scottchou | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++17 | 2 ms | 588 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<queue>
using namespace std;
int const N = 2005;
typedef long long LL;
LL const inf = 1e18;
LL a[N], dif[N];
LL suf[N];
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
dif[i] = a[i] - a[i - 1];
}
for(int i = n; i > 0; i--){
suf[i] = suf[i + 1];
if(dif[i] >= 0){
suf[i] += dif[i] + 1;
}
}
LL ans = inf, pre = 0;
for(int i = 1; i <= n; i++){
if(dif[i] <= 0){
pre += (-dif[i]) + 1;
}
ans = min(ans, max(pre, suf[i + 1]));
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |