Submission #71484077


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a),E##i=(b);i<=E##i;i++)
#define REV(i,a,b) for(int i=(a),E##i=(b);i>=E##i;i--)
#define CLOSE_TIE ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define psbk push_back
#define endl '\n'
template <typename T>
void _outval(string s,int p,const T &t) {cout<<s.substr(p,s.length()-p)<<'='<<t<<endl; }
template <typename T, typename... Args>
void _outval(string s,int p,const T &t,const Args &...rest){
    string n="";
    while(s[p]!=',') n+=s[p++];
    cout<<n<<'='<<t<<", ";
    _outval(s,p+1,rest...);
}
#define outval(...) _outval(#__VA_ARGS__,0,__VA_ARGS__)
#define outarr(a,be,ed)\
{cout<<(#a)<<": ";\
FOR(iiii,be,ed)cout<<'['<<iiii<<"]="<<a[iiii]<<(iiii<ed?", ":"\n");}
const int N=5e5+5;
int n,a[N],ans;
signed main(){
    CLOSE_TIE
    cin>>n;
    FOR(i,1,n) cin>>a[i];
    int r=1;
    FOR(i,1,n){
        if(i>r) break;
        r=max(r,i+a[i]-1);
        if(r>=n) break;
    }
    cout<<min(n,r);
    return 0;
}

Submission Info

Submission Time
Task C - Domino
User FYCCCTA2011
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1054 Byte
Status AC
Exec Time 17 ms
Memory 5660 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 1 ms 3524 KiB
random_01.txt AC 16 ms 5612 KiB
random_02.txt AC 7 ms 4204 KiB
random_03.txt AC 16 ms 5612 KiB
random_04.txt AC 4 ms 3872 KiB
random_05.txt AC 16 ms 5536 KiB
random_06.txt AC 16 ms 5440 KiB
random_07.txt AC 16 ms 5660 KiB
random_08.txt AC 9 ms 4716 KiB
random_09.txt AC 16 ms 5524 KiB
random_10.txt AC 13 ms 5352 KiB
random_11.txt AC 17 ms 5616 KiB
random_12.txt AC 5 ms 4208 KiB
random_13.txt AC 11 ms 5468 KiB
random_14.txt AC 15 ms 5468 KiB
random_15.txt AC 15 ms 5572 KiB
random_16.txt AC 15 ms 5552 KiB
sample_01.txt AC 1 ms 3564 KiB
sample_02.txt AC 1 ms 3688 KiB
sample_03.txt AC 1 ms 3488 KiB