結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 1000000007;
//const int mod = 998244353;

int main()
{
  int n, k;
  cin >> n >> k;
  int m1;
  cin >> m1;
  vector<int> a(m1);
  rep(i, 0, m1) cin >> a[i];
  map<int, int> mp;
  rep(i, 0, m1) mp[a[i]] = 1;
  int m2;
  cin >> m2;
  vector<int> b(m2);
  rep(i, 0, m2) cin >> b[i];
  map<int, int> mpp;
  rep(i, 0, m2) mpp[b[i]] = 1;
  vector<int> dp(n+1);
  dp[0] = 1;
  rep(i, 1, n+1) {
    if (dp[i-1]) dp[i] = 1;
    if (i - k >= 0) {
      if (dp[i - k]) dp[i] = 1;
    }
    if (mp[i]) dp[i] = 0;
    if (mpp[i]) dp[i] = 1;
  }
  if (dp[n]) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}
0