제출 #711905

#제출 시각아이디문제언어결과실행 시간메모리
711905deme_bzGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
58 ms6944 KiB

#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define eb emplace_back
#define sz(x) (int)x.size()
using namespace std;
const int N=2e6+5;

ll pre[N],A[N],suf[N];
void test_case(){
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> A[i];
	}
	for(int i=1;i<=n;i++){
		pre[i]=pre[i-1]+max(0LL,A[i-1]-A[i]+1);
	}
	reverse(A+1,A+1+n);
	for(int i=1;i<=n;i++){
		suf[i]=suf[i-1]+max(0LL,A[i-1]-A[i]+1);
	}
	reverse(A+1,A+1+n);
	ll answer=1e18;
	for(int i=1;i<=n;i++){
		answer=min(answer,max(pre[i],suf[n-i+1]));
	}
	cout << answer << endl;
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int T = 1;
    //cin >> T;
    while(T--){
        test_case();
    }
}

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

Main.cpp:2:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    2 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
Main.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...