Submission #71482573


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize(2)
/*i32 : -2e9~2e9
i64: -9e18~9e18
ui64: 0~1.8e19*/
typedef unsigned long long ull;
typedef unsigned long long ui64;
typedef long long i64;
typedef long long ll;
#define umap unordered_map
#define forrr(A) for (int i = 1; i <= A; i++)
#define range(s,e) for (int j=s;j!=e;(s<e?j++:j--))
#define endl '\n'
#define debug(A) cout << #A << "==" << A << '\n';
#define pb push_back
#define point pair<int, int>
#define all(A) A.begin(), A.end()
#define eps(A) fixed << setprecision(A)
#define nextp(A) next_permutation(A.begin(), A.end())
//#define int long long
const int MAXN = 1e5 + 5, MOD = 1e9 + 7;
int n, m, t, ar[MAXN], ans, cnt, k;
void dxy(int &x, int &y, point p) { x = p.first, y = p.second; }
void solve() { 
    cin >> n;
    vector<int> a(n);
    for(auto &x : a) cin >> x;
    int mx = 0;
    for(int i = 0; i < n; i++) {
        if(i <= mx) {
            mx = max(mx, i + a[i] - 1);
            ans++;
        }
    }
    cout << ans << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int times = 1;// cin >> times;
    while (times--) solve();
    return 0;
}

Submission Info

Submission Time
Task C - Domino
User unaptx4869
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1237 Byte
Status AC
Exec Time 17 ms
Memory 5376 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 3628 KiB
random_01.txt AC 17 ms 5376 KiB
random_02.txt AC 8 ms 4036 KiB
random_03.txt AC 17 ms 5300 KiB
random_04.txt AC 4 ms 3684 KiB
random_05.txt AC 17 ms 5228 KiB
random_06.txt AC 16 ms 5168 KiB
random_07.txt AC 17 ms 5312 KiB
random_08.txt AC 10 ms 4404 KiB
random_09.txt AC 17 ms 5376 KiB
random_10.txt AC 14 ms 4784 KiB
random_11.txt AC 17 ms 5244 KiB
random_12.txt AC 6 ms 3836 KiB
random_13.txt AC 11 ms 5320 KiB
random_14.txt AC 16 ms 5312 KiB
random_15.txt AC 16 ms 5300 KiB
random_16.txt AC 15 ms 5244 KiB
sample_01.txt AC 1 ms 3460 KiB
sample_02.txt AC 1 ms 3460 KiB
sample_03.txt AC 1 ms 3596 KiB