Submission #71484534


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int n;
	cin>>n;
	vector<int>a(n+1,0);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int maxn=1+a[0];
	for(int i=1;i<=n;i++){
		if(i<=maxn){
		maxn=max(maxn,i+a[i]-1);
		}
	}
	cout<<min(maxn,n)<<"\n";
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1; //cin >> T;
	while(T--) solve();
    return 0;
}

Submission Info

Submission Time
Task C - Domino
User fireskybaby
Language C++23 (GCC 15.2.0)
Score 300
Code Size 426 Byte
Status AC
Exec Time 22 ms
Memory 7372 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
min.txt AC 2 ms 3424 KiB
random_01.txt AC 21 ms 7372 KiB
random_02.txt AC 10 ms 4820 KiB
random_03.txt AC 22 ms 7372 KiB
random_04.txt AC 5 ms 4052 KiB
random_05.txt AC 21 ms 7232 KiB
random_06.txt AC 20 ms 7120 KiB
random_07.txt AC 21 ms 7120 KiB
random_08.txt AC 13 ms 5512 KiB
random_09.txt AC 21 ms 7200 KiB
random_10.txt AC 18 ms 6460 KiB
random_11.txt AC 21 ms 7160 KiB
random_12.txt AC 7 ms 4456 KiB
random_13.txt AC 15 ms 7372 KiB
random_14.txt AC 20 ms 7244 KiB
random_15.txt AC 20 ms 7120 KiB
random_16.txt AC 20 ms 7228 KiB
sample_01.txt AC 1 ms 3596 KiB
sample_02.txt AC 2 ms 3632 KiB
sample_03.txt AC 2 ms 3540 KiB