結果
問題 | No.2402 Dirty Stairs and Shoes |
ユーザー |
|
提出日時 | 2023-08-07 20:22:30 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 1,308 bytes |
コンパイル時間 | 2,371 ms |
コンパイル使用メモリ | 111,428 KB |
実行使用メモリ | 40,836 KB |
最終ジャッジ日時 | 2024-12-20 02:50:13 |
合計ジャッジ時間 | 4,843 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;class Program{static void Main(string[] args){int N, K, M1, M2;int[] A = new int[0];int[] B = new int[0];var nk = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);N = nk[0];K = nk[1];M1 = int.Parse(Console.ReadLine());if(M1>0) A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);M2 = int.Parse(Console.ReadLine());if(M2>0) B = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);var C = new int[N + 1];foreach(var a in A){C[a] = -1;}foreach(var b in B){C[b] = 1;}var D = new bool[N + 1];D[0] = true;for(int i=0;i<N;i++){if(C[i]==1){D[i] = true;}if(D[i]){if(C[i+1]!=-1){D[i + 1] = true;}if(i+K<=N&&C[i+K]!=-1){D[i + K] = true;}}}Console.WriteLine(D[N] ? "Yes" : "No");}}