結果

問題 No.801 エレベーター
ユーザー tentententen
提出日時 2020-09-02 08:34:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 1,256 bytes
コンパイル時間 3,001 ms
コンパイル使用メモリ 73,688 KB
実行使用メモリ 94,000 KB
最終ジャッジ日時 2023-08-13 17:44:53
合計ジャッジ時間 15,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,836 KB
testcase_01 AC 123 ms
55,896 KB
testcase_02 AC 126 ms
55,884 KB
testcase_03 AC 202 ms
56,660 KB
testcase_04 AC 198 ms
56,332 KB
testcase_05 AC 195 ms
55,956 KB
testcase_06 AC 196 ms
56,404 KB
testcase_07 AC 198 ms
56,068 KB
testcase_08 AC 199 ms
56,748 KB
testcase_09 AC 196 ms
55,976 KB
testcase_10 AC 197 ms
56,460 KB
testcase_11 AC 194 ms
56,004 KB
testcase_12 AC 194 ms
56,008 KB
testcase_13 AC 546 ms
90,048 KB
testcase_14 AC 521 ms
91,916 KB
testcase_15 AC 534 ms
92,128 KB
testcase_16 AC 522 ms
91,752 KB
testcase_17 AC 537 ms
92,224 KB
testcase_18 AC 536 ms
94,000 KB
testcase_19 AC 520 ms
92,032 KB
testcase_20 AC 534 ms
92,104 KB
testcase_21 AC 526 ms
93,248 KB
testcase_22 AC 543 ms
92,852 KB
testcase_23 AC 522 ms
92,044 KB
testcase_24 AC 527 ms
91,648 KB
testcase_25 AC 518 ms
92,572 KB
testcase_26 AC 511 ms
91,988 KB
testcase_27 AC 522 ms
92,176 KB
testcase_28 AC 533 ms
92,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[] lefts = new int[m];
        int[] rights = new int[m];
        for (int i = 0; i < m; i++) {
            lefts[i] = sc.nextInt();
            rights[i] = sc.nextInt();
        }
        int[][] dp = new int[k + 1][n + 2];
        Arrays.fill(dp[0], 1);
        dp[0][0] = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 0; j < m; j++) {
                int sum = (dp[i - 1][rights[j]] - dp[i - 1][lefts[j] - 1] + MOD) % MOD;
                dp[i][lefts[j]] += sum;
                dp[i][lefts[j]] %= MOD;
                dp[i][rights[j] + 1] += MOD - sum;
                dp[i][rights[j] + 1] %= MOD;
            }
            for (int j = 1; j <= n; j++) {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
            for (int j = 1; j <= n; j++) {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
        }
        System.out.println((dp[k][n] - dp[k][n - 1] + MOD) % MOD);
    }
}
0