Submission #627930


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    const int MOD = (int)1e9 + 7;

    static int CalcNaive(int n, int k) {
       var dp = new int[n+1, k]; // [駅, 連続して停止した駅数]

       dp[1, 1] = 1;
       for (int i = 2; i <= n; i++) { // i 番目の駅

           // i 番目の駅で停車する
           for (int j = 0; j < k-1; j++) {
               dp[i, j+1] = (dp[i, j+1] + dp[i-1, j]) % MOD;
           }

           // i 番目の駅で停車しない
           for (int j = 0; j < k; j++) {
               dp[i, 0] = (dp[i, 0] + dp[i-1, j]) % MOD;
           }
       }

       int ans = 0;
       for (int i = 1; i < k; i++) {
           ans = (ans + dp[n, i]) % MOD;
       }

       return ans;
    }

    static void Main() {
        var nk = ReadInts();
        int n = nk[0], k = nk[1];

        Console.WriteLine(CalcNaive(n, k));

    }
}

Submission Info

Submission Time
Task F - 準急
User noriok
Language C# (Mono 2.10.8.1)
Score 0
Code Size 1236 Byte
Status RE
Exec Time 889 ms
Memory 84664 KB

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
AC × 4
RE × 3
Set Name Test Cases
All 00, 01, 02, 03, 04, 90, 91
Case Name Status Exec Time Memory
00 AC 185 ms 16412 KB
01 RE 123 ms 8508 KB
02 RE 124 ms 8636 KB
03 RE 127 ms 8632 KB
04 AC 889 ms 84664 KB
90 AC 123 ms 8608 KB
91 AC 121 ms 8740 KB