Submission #71479529


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define debug(arg) cout << "[" << #arg << "]: " << arg << endl
#else
#define debug(arg) 42
#endif

using llu = uint64_t;
using ll = int64_t;

#define vec vector
#define pb push_back
#define all(n) begin(n), end(n)

void solv() {
	int n; cin >> n;
	vec<int> a(n); for (auto &i : a) cin >> i;
	int l = 0, r = 0;
	while (r < n - 1) {
		int mxj = r;
		for (int i = l; i <= r; ++i) mxj = max(mxj, a[i] + i - 1);
		mxj = min(mxj, n - 1);
		if (mxj == r) break;
		l = r + 1;
		r = mxj;
		debug(l << ' ' << r);
	}
	cout << r + 1 << '\n';
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) solv();
	return 0;
}

Submission Info

Submission Time
Task C - Domino
User fisher199
Language C++23 (Clang 21.1.0)
Score 300
Code Size 752 Byte
Status AC
Exec Time 164 ms
Memory 4904 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 2892 KiB
random_01.txt AC 159 ms 4904 KiB
random_02.txt AC 60 ms 3704 KiB
random_03.txt AC 162 ms 4840 KiB
random_04.txt AC 29 ms 3412 KiB
random_05.txt AC 157 ms 4840 KiB
random_06.txt AC 154 ms 4876 KiB
random_07.txt AC 154 ms 4744 KiB
random_08.txt AC 82 ms 3976 KiB
random_09.txt AC 159 ms 4840 KiB
random_10.txt AC 122 ms 4428 KiB
random_11.txt AC 157 ms 4808 KiB
random_12.txt AC 44 ms 3396 KiB
random_13.txt AC 88 ms 4860 KiB
random_14.txt AC 164 ms 4804 KiB
random_15.txt AC 162 ms 4804 KiB
random_16.txt AC 161 ms 4840 KiB
sample_01.txt AC 1 ms 3060 KiB
sample_02.txt AC 1 ms 2936 KiB
sample_03.txt AC 1 ms 3100 KiB