結果
| 問題 |
No.2402 Dirty Stairs and Shoes
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-04 21:29:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 1,041 bytes |
| コンパイル時間 | 2,069 ms |
| コンパイル使用メモリ | 173,460 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-20 02:25:07 |
| 合計ジャッジ時間 | 2,945 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> istream& operator >> (istream& is, vector<T>& vec) {
for(T& x : vec) is >> x;
return is;
}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
if(vec.empty()) return os;
os << vec[0];
for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
return os;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, m1, m2;
cin >> n >> k >> m1;
vector<int> a(m1);
cin >> a >> m2;
vector<int> b(m2);
cin >> b;
vector<bool> dp(n + 1);
sort(a.begin(), a.end());
sort(b.begin(), b.end());
dp[0] = true;
for(int i = 0; i < n; i++){
if(binary_search(a.begin(), a.end(), i))continue;
if(binary_search(b.begin(), b.end(), i)){
dp[i] = true;
}
if(dp[i]){
if(i + 1 <= n) dp[i + 1] = true;
if(i + k <= n) dp[i + k] = true;
}
}
cout << (dp[n] ? "Yes" : "No") << '\n';
}