Submission #5846757


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();

        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;

        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 0
Code Size 1052 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 0 / 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 93 ms 21844 KB
02.txt 93 ms 21204 KB
03.txt 93 ms 19284 KB
04.txt 92 ms 19796 KB
05.txt 94 ms 19156 KB
06.txt 93 ms 21332 KB
07.txt 94 ms 21588 KB
08.txt 93 ms 19156 KB
09.txt 92 ms 21204 KB
10.txt 92 ms 20816 KB
11.txt 95 ms 20820 KB
12.txt 97 ms 19028 KB
13.txt 93 ms 19668 KB
14.txt 92 ms 19156 KB
15.txt 93 ms 21716 KB
16.txt
17.txt 244 ms 25012 KB
18.txt 1342 ms 40144 KB
19.txt 1582 ms 39408 KB
20.txt 149 ms 20640 KB
21.txt 543 ms 35980 KB
22.txt 127 ms 21588 KB
23.txt
24.txt 801 ms 32728 KB
25.txt 890 ms 29272 KB
26.txt 103 ms 20812 KB
27.txt 321 ms 23208 KB
28.txt
29.txt
30.txt 449 ms 25016 KB
31.txt
32.txt
33.txt
s1.txt 93 ms 19028 KB
s2.txt 96 ms 21204 KB
s3.txt 94 ms 19284 KB