Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
28364 23级.刘展翔 【J】T2 C++ 通过 100 16 MS 472 KB 524 2024-04-14 14:47:13

Tests(10/10):


#include<iostream> using namespace std; const int maxn = 1e5 + 15; int a[maxn]; int main(){ int n, cnt = 0; cin >> n; int l = 1, f = 1; for(int i = 1, m;i <= n;i++){ cin >> m; if(i > l) a[cnt++] = f; if(i + m > l){ l = i + m; f = i; } } if(l < n + 1){ a[cnt++] = f; } cout << cnt << endl; for(int i = 0;i < cnt;i++){ cout << a[i] << " "; } return 0; } //5 4 3 3 2 1 0 0 0 1 0 0 //


测评信息: