Submission #5864593


Source Code Expand

Copy
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);
    }

}

Submission Info

Submission Time
Task C - Typical Stairs
User alkwest
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 1053 Byte
Status
Exec Time 438 ms
Memory 64500 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 300 / 300 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
Case Name Status Exec Time Memory
01.txt 95 ms 21588 KB
02.txt 94 ms 23124 KB
03.txt 92 ms 18772 KB
04.txt 93 ms 21716 KB
05.txt 94 ms 21844 KB
06.txt 93 ms 18892 KB
07.txt 92 ms 18516 KB
08.txt 93 ms 21844 KB
09.txt 92 ms 19796 KB
10.txt 94 ms 21588 KB
11.txt 92 ms 18772 KB
12.txt 95 ms 19412 KB
13.txt 93 ms 18772 KB
14.txt 95 ms 17748 KB
15.txt 93 ms 19284 KB
16.txt 398 ms 61120 KB
17.txt 164 ms 25944 KB
18.txt 262 ms 40996 KB
19.txt 273 ms 45732 KB
20.txt 114 ms 18896 KB
21.txt 238 ms 37224 KB
22.txt 122 ms 20944 KB
23.txt 312 ms 43632 KB
24.txt 194 ms 29040 KB
25.txt 193 ms 27964 KB
26.txt 105 ms 22228 KB
27.txt 156 ms 25580 KB
28.txt 438 ms 64500 KB
29.txt 354 ms 44676 KB
30.txt 160 ms 26448 KB
31.txt 317 ms 44612 KB
32.txt 310 ms 45960 KB
33.txt 341 ms 44308 KB
s1.txt 92 ms 18644 KB
s2.txt 96 ms 20692 KB
s3.txt 95 ms 19664 KB