結果
| 問題 | 
                            No.1242 高橋君とすごろく
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tenten
                         | 
                    
| 提出日時 | 2020-11-20 11:53:12 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 150 ms / 2,000 ms | 
| コード長 | 937 bytes | 
| コンパイル時間 | 2,257 ms | 
| コンパイル使用メモリ | 78,580 KB | 
| 実行使用メモリ | 54,576 KB | 
| 最終ジャッジ日時 | 2024-07-23 12:01:52 | 
| 合計ジャッジ時間 | 7,393 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 24 | 
ソースコード
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int k = sc.nextInt();
		TreeSet<Long> out = new TreeSet<>();
		for (int i = 0; i < k; i++) {
		    out.add(sc.nextLong());
		}
		Long current = Long.MAX_VALUE;
		while ((current = out.lower(current)) != null) {
		    int count = 0;
		    long target = current - 4;
		    if (target > 0 && out.contains(target + 3)) {
		        out.add(target);
		        count++;
		    }
		    target = current - 5;
		    if (target > 0 && out.contains(target + 2)) {
		        out.add(target);
		        count++;
		    }
		    target = current - 6;
		    if (target > 0 && out.contains(target + 1)) {
		        out.add(target);
		        count++;
		    }
		    if (count >= 3 || out.contains(1L)) {
		        System.out.println("No");
		        return;
		    }
		}
		System.out.println("Yes");
   }
}
            
            
            
        
            
tenten