提出 #5864593
ソースコード 拡げる
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
HashSet<Integer> holeList = new HashSet<>();
for (int i = 0; i < m; i++){
holeList.add(sc.nextInt());
}
long count = 0;
long countOneBefore = 1;
long countTwoBefore = 0;
for (int i = 0 ; i < n; i++){
if (holeList.contains(i + 1)){
// 穴が開いている場合
count = 0;
countTwoBefore = countOneBefore;
countOneBefore = count;
}else {
count = countOneBefore + countTwoBefore;
if (count >= 1000000007L){
count = count % 1000000007L;
}
countTwoBefore = countOneBefore;
countOneBefore = count;
}
}
System.out.println(count);
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Typical Stairs |
| ユーザ | alkwest |
| 言語 | Java8 (OpenJDK 1.8.0) |
| 得点 | 300 |
| コード長 | 1053 Byte |
| 結果 | AC |
| 実行時間 | 438 ms |
| メモリ | 64500 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, s1.txt, s2.txt, s3.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01.txt | AC | 95 ms | 21588 KiB |
| 02.txt | AC | 94 ms | 23124 KiB |
| 03.txt | AC | 92 ms | 18772 KiB |
| 04.txt | AC | 93 ms | 21716 KiB |
| 05.txt | AC | 94 ms | 21844 KiB |
| 06.txt | AC | 93 ms | 18892 KiB |
| 07.txt | AC | 92 ms | 18516 KiB |
| 08.txt | AC | 93 ms | 21844 KiB |
| 09.txt | AC | 92 ms | 19796 KiB |
| 10.txt | AC | 94 ms | 21588 KiB |
| 11.txt | AC | 92 ms | 18772 KiB |
| 12.txt | AC | 95 ms | 19412 KiB |
| 13.txt | AC | 93 ms | 18772 KiB |
| 14.txt | AC | 95 ms | 17748 KiB |
| 15.txt | AC | 93 ms | 19284 KiB |
| 16.txt | AC | 398 ms | 61120 KiB |
| 17.txt | AC | 164 ms | 25944 KiB |
| 18.txt | AC | 262 ms | 40996 KiB |
| 19.txt | AC | 273 ms | 45732 KiB |
| 20.txt | AC | 114 ms | 18896 KiB |
| 21.txt | AC | 238 ms | 37224 KiB |
| 22.txt | AC | 122 ms | 20944 KiB |
| 23.txt | AC | 312 ms | 43632 KiB |
| 24.txt | AC | 194 ms | 29040 KiB |
| 25.txt | AC | 193 ms | 27964 KiB |
| 26.txt | AC | 105 ms | 22228 KiB |
| 27.txt | AC | 156 ms | 25580 KiB |
| 28.txt | AC | 438 ms | 64500 KiB |
| 29.txt | AC | 354 ms | 44676 KiB |
| 30.txt | AC | 160 ms | 26448 KiB |
| 31.txt | AC | 317 ms | 44612 KiB |
| 32.txt | AC | 310 ms | 45960 KiB |
| 33.txt | AC | 341 ms | 44308 KiB |
| s1.txt | AC | 92 ms | 18644 KiB |
| s2.txt | AC | 96 ms | 20692 KiB |
| s3.txt | AC | 95 ms | 19664 KiB |