結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー erbowl
提出日時 2023-08-04 21:30:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 981 bytes
コンパイル時間 2,364 ms
コンパイル使用メモリ 196,908 KB
最終ジャッジ日時 2025-02-15 22:23:33
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n,k;
    std::cin >> n>>k;
    ll m1;
    std::cin >> m1;
    vector<bool> yogo(n+1);
    for (int i = 0; i < m1; i++) {
        ll a;
        std::cin >> a;
        yogo[a]=true;
    }
    vector<bool> mat(n+1);
    std::cin >> m1;
    for (int i = 0; i < m1; i++) {
        ll a;
        std::cin >> a;
        mat[a]=true;
    }
    vector<bool> dp(n+1);
    dp[0]=true;
    for (int i = 1; i <= n; i++) {
        if(mat[i]){
            dp[i]=true;
            continue;
        }
        if(yogo[i]){
            continue;
        }
        if(dp[i-1]){
            dp[i]=true;
            continue;
        }
        if(i-k>=0&&dp[i-k]){
            dp[i]=true;
            continue;
        }
        dp[i]=false;
    }
    if(dp[n]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
};
0