Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
28361 23级.刘展翔 【J】T2 C++ 解答错误 70 16 MS 468 KB 493 2024-04-14 14:45:54

Tests(7/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(f < n + 1){ a[cnt++] = f; } cout << cnt << endl; for(int i = 0;i < cnt;i++){ cout << a[i] << " "; } return 0; }


测评信息: