Submission #71489135
Source Code Expand
#include <iostream>
#include <unordered_map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
void solve() {
unsigned long long n;
cin >> n;
vector<unsigned long long> a(n);
for (int i = 0; i < n; i++)cin >> a[i];
unsigned long long last = min(a[0] - 1,n-1);
unsigned long long i = 0;
while (i <= last) {
unsigned long long nxt = i + a[i] - 1;
last = min(max(last, nxt),n-1);
i++;
}
cout << last + 1;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Domino |
| User | alexxy |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 656 Byte |
| Status | AC |
| Exec Time | 20 ms |
| Memory | 7296 KiB |
Compile Error
./Main.cpp: In function 'void solve()':
./Main.cpp:17:35: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
17 | for (int i = 0; i < n; i++)cin >> a[i];
| ~~^~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | 3604 KiB |
| random_01.txt | AC | 20 ms | 7296 KiB |
| random_02.txt | AC | 9 ms | 4784 KiB |
| random_03.txt | AC | 20 ms | 7112 KiB |
| random_04.txt | AC | 5 ms | 3940 KiB |
| random_05.txt | AC | 20 ms | 7164 KiB |
| random_06.txt | AC | 19 ms | 7096 KiB |
| random_07.txt | AC | 19 ms | 7248 KiB |
| random_08.txt | AC | 12 ms | 5488 KiB |
| random_09.txt | AC | 19 ms | 7140 KiB |
| random_10.txt | AC | 17 ms | 6476 KiB |
| random_11.txt | AC | 20 ms | 7244 KiB |
| random_12.txt | AC | 6 ms | 4380 KiB |
| random_13.txt | AC | 14 ms | 7248 KiB |
| random_14.txt | AC | 19 ms | 7228 KiB |
| random_15.txt | AC | 18 ms | 7152 KiB |
| random_16.txt | AC | 19 ms | 7112 KiB |
| sample_01.txt | AC | 1 ms | 3460 KiB |
| sample_02.txt | AC | 1 ms | 3576 KiB |
| sample_03.txt | AC | 1 ms | 3496 KiB |