// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432 // 动态规划,只要可以跳到的各自中有一个可以到达终点那么这个格子就可以到达终点 #include<iostream> #include<bitset> #define pre(i,j,k) for (int i = j;i < k; i++) #include<vector> using namespace std; bitset<200010> dp; int main(){ ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr); int n; cin >> n; vector<int> a(n); dp[n - 1] = 1; pre(i, 0, n) cin >> a[i]; for (int i = n - 2; i >= 0; i--){ int hvend = min(200005, i + a[i]);//-------这里注意防止越界,也是一点点剪枝 pre(j, i, hvend + 1){ if (dp[j]){ dp[i] = 1; break; } } } if (dp[0]) cout << "true"; else cout << "false"; return 0; } // 64 位输出请用 printf("%lld")