LOADING

加载过慢请开启缓存,浏览器默认开启

daily 1

2023/6/4 daily

CF 1741 E

void solve(){
  int n;
  cin>>n;
  vector<int>dp(2*n+1),a(n+1);
  for(int i=1;i<=n;++i)cin>>a[i];
  dp[0]=1;
  for(int i=0;i<=n;++i){
   if(i-a[i]-1>=0&&dp[i-a[i]-1]){
        dp[i]=1;
   }
   if(i+a[i]+1<=n&&dp[i]){
        dp[i+a[i]+1]=1;
   }
  }
  cout<<(dp[n]?"YES":"NO")<<'\n';
  return;
}