제출 #975601

#제출 시각아이디문제언어결과실행 시간메모리
975601IsamGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h>
using namespace std;

#define eb emplace_back
#define all(x) x.begin(), x.end()
#define int long long

constexpr int sz = 2e5 + 5;

int n, a[sz], pref[sz], suff[sz], b[sz];

int ans = (int)1E18;

signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(register int i = 1; i <= n; ++i){
		cin >> a[i], b[i] = a[i];
	}
	
	for(register int i = 1; i <= n; ++i){
		pref[i] = pref[i-1];
		if(b[i] > b[i-1]) continue;
		b[i] = (pref[i] += b[i-1] - b[i] + 1, b[i-1] + 1);
	}
	
	for(register int i = n; i >= 1; --i){
		suff[i] = suff[i+1];
		if(a[i] > a[i+1]) continue;
		a[i] = (suff[i] += a[i+1] - a[i] + 1, a[i+1] + 1);
	}
	
	for(register int i = 1; i <= n; ++i){
		ans = min(ans, max(pref[i], suff[i]));
	}
	
	cout << ans << '\n';
	
	
}

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

Main.cpp: In function 'int main()':
Main.cpp:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |  for(register int i = 1; i <= n; ++i){
      |                   ^
Main.cpp:21:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |  for(register int i = 1; i <= n; ++i){
      |                   ^
Main.cpp:27:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |  for(register int i = n; i >= 1; --i){
      |                   ^
Main.cpp:33:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |  for(register int i = 1; i <= n; ++i){
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...