提出 #5849100
ソースコード 拡げる
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();
List<Integer> holeList = new ArrayList<>();
for (int i = 0; i < m; i++){
holeList.add(sc.nextInt());
}
long count = 0;
long countOneBefore = 1;
long countTwoBefore = 0;
int holeIndex = 0;
int holeStair = 0;
if (holeList.size() != 0){
holeStair = holeList.get(holeIndex);
}
for (int i = 0 ; i < n; i++){
if (holeStair == (i + 1)){
// 穴が開いている場合
count = 0;
countTwoBefore = countOneBefore;
countOneBefore = count;
holeIndex += 1;
holeStair = holeList.get(Math.min(holeIndex, m - 1));
}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 |
| コード長 | 1311 Byte |
| 結果 | AC |
| 実行時間 | 436 ms |
| メモリ | 59400 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 | 19028 KiB |
| 02.txt | AC | 96 ms | 19924 KiB |
| 03.txt | AC | 95 ms | 21716 KiB |
| 04.txt | AC | 96 ms | 22608 KiB |
| 05.txt | AC | 97 ms | 19540 KiB |
| 06.txt | AC | 96 ms | 18644 KiB |
| 07.txt | AC | 96 ms | 19796 KiB |
| 08.txt | AC | 95 ms | 18900 KiB |
| 09.txt | AC | 96 ms | 21844 KiB |
| 10.txt | AC | 96 ms | 19156 KiB |
| 11.txt | AC | 95 ms | 18644 KiB |
| 12.txt | AC | 98 ms | 19284 KiB |
| 13.txt | AC | 94 ms | 19796 KiB |
| 14.txt | AC | 96 ms | 21844 KiB |
| 15.txt | AC | 96 ms | 21716 KiB |
| 16.txt | AC | 405 ms | 46372 KiB |
| 17.txt | AC | 162 ms | 27852 KiB |
| 18.txt | AC | 253 ms | 38564 KiB |
| 19.txt | AC | 243 ms | 35732 KiB |
| 20.txt | AC | 117 ms | 21204 KiB |
| 21.txt | AC | 250 ms | 40088 KiB |
| 22.txt | AC | 115 ms | 21716 KiB |
| 23.txt | AC | 257 ms | 39264 KiB |
| 24.txt | AC | 194 ms | 30236 KiB |
| 25.txt | AC | 192 ms | 27448 KiB |
| 26.txt | AC | 111 ms | 20560 KiB |
| 27.txt | AC | 139 ms | 24020 KiB |
| 28.txt | AC | 436 ms | 59400 KiB |
| 29.txt | AC | 347 ms | 48836 KiB |
| 30.txt | AC | 150 ms | 25580 KiB |
| 31.txt | AC | 253 ms | 38576 KiB |
| 32.txt | AC | 314 ms | 42824 KiB |
| 33.txt | AC | 351 ms | 46176 KiB |
| s1.txt | AC | 95 ms | 21844 KiB |
| s2.txt | AC | 96 ms | 19796 KiB |
| s3.txt | AC | 96 ms | 20948 KiB |