Submission #71474725


Source Code Expand

/*
    JAI JAGANNATH!
*/
//@Author : zanj0

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

// #define LOCAL  // ← enable locally via -DLOCAL; keep commented for OJ
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
#define inf 1000000000000000000LL
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define endl "\n"
#define timetaken cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC << "ms\n"

typedef long long int lli;

#ifdef LOCAL
#define dbg(x) cerr << "[DBG] " << #x << " = " << (x) << '\n'
template <class A, class B>
ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ',' << p.second << ')'; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    for (size_t i = 0; i < v.size(); ++i)
    {
        if (i)
            os << ',';
        os << v[i];
    }
    return os << ']';
}
template <class K, class V>
ostream &operator<<(ostream &os, const map<K, V> &mp)
{
    os << '{';
    bool first = true;
    for (const auto &kv : mp)
    {
        if (!first)
            os << ',';
        first = false;
        os << kv.first << ':' << kv.second;
    }
    return os << '}';
}
template <class K, class V>
ostream &operator<<(ostream &os, const unordered_map<K, V> &mp)
{
    os << '{';
    bool first = true;
    for (const auto &kv : mp)
    {
        if (!first)
            os << ',';
        first = false;
        os << kv.first << ':' << kv.second;
    }
    return os << '}';
}
#else
#define dbg(x) ((void)0)
#endif

void zanj0()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
}

/*
────────────────────────────────────────────────────────────────────────
    Problem Statement:

    Observations:

    Claims:

────────────────────────────────────────────────────────────────────────
*/

void Solve()
{
    lli n;
    cin >> n;

    lli ret = 0;

    vector<lli> v(n);

    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    ret = 1;
    lli right = 1 + v[0] - 1;
    for(lli i = 1; i < n; i++){
        if(i < right){
            right = max(right, i + 1 + v[i] - 1);
            ret++;
        }else break;
    }

    cout << ret << endl;
}

int32_t main()
{
    zanj0();
    Solve();
    timetaken;
    return 0;
}

/*
    GOLDEN RULES
    • Solutions are simple.
    • Proofs are simple.
    • Implementations are simple.
*/

Submission Info

Submission Time
Task C - Domino
User zanj0
Language C++23 (GCC 15.2.0)
Score 300
Code Size 3240 Byte
Status AC
Exec Time 18 ms
Memory 7288 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 3816 KiB
random_01.txt AC 17 ms 7168 KiB
random_02.txt AC 8 ms 4732 KiB
random_03.txt AC 17 ms 7288 KiB
random_04.txt AC 4 ms 4156 KiB
random_05.txt AC 17 ms 7224 KiB
random_06.txt AC 16 ms 7096 KiB
random_07.txt AC 17 ms 7224 KiB
random_08.txt AC 10 ms 5372 KiB
random_09.txt AC 17 ms 7288 KiB
random_10.txt AC 14 ms 6396 KiB
random_11.txt AC 18 ms 7232 KiB
random_12.txt AC 6 ms 4392 KiB
random_13.txt AC 12 ms 7228 KiB
random_14.txt AC 16 ms 7212 KiB
random_15.txt AC 16 ms 7216 KiB
random_16.txt AC 16 ms 7192 KiB
sample_01.txt AC 1 ms 3668 KiB
sample_02.txt AC 1 ms 3856 KiB
sample_03.txt AC 1 ms 3836 KiB