結果

問題 No.801 エレベーター
ユーザー htensaihtensai
提出日時 2019-12-11 11:27:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 561 ms / 2,000 ms
コード長 1,311 bytes
コンパイル時間 2,533 ms
コンパイル使用メモリ 73,492 KB
実行使用メモリ 128,676 KB
最終ジャッジ日時 2023-09-06 13:01:44
合計ジャッジ時間 14,704 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,536 KB
testcase_01 AC 113 ms
55,636 KB
testcase_02 AC 114 ms
56,348 KB
testcase_03 AC 197 ms
58,784 KB
testcase_04 AC 200 ms
58,936 KB
testcase_05 AC 204 ms
58,300 KB
testcase_06 AC 203 ms
58,812 KB
testcase_07 AC 201 ms
58,004 KB
testcase_08 AC 198 ms
58,360 KB
testcase_09 AC 189 ms
58,240 KB
testcase_10 AC 189 ms
59,220 KB
testcase_11 AC 186 ms
58,372 KB
testcase_12 AC 184 ms
59,036 KB
testcase_13 AC 533 ms
126,936 KB
testcase_14 AC 520 ms
126,284 KB
testcase_15 AC 527 ms
128,400 KB
testcase_16 AC 523 ms
128,192 KB
testcase_17 AC 509 ms
126,684 KB
testcase_18 AC 545 ms
126,768 KB
testcase_19 AC 512 ms
126,852 KB
testcase_20 AC 561 ms
126,236 KB
testcase_21 AC 540 ms
126,712 KB
testcase_22 AC 514 ms
126,176 KB
testcase_23 AC 507 ms
128,636 KB
testcase_24 AC 523 ms
126,804 KB
testcase_25 AC 518 ms
126,744 KB
testcase_26 AC 519 ms
128,224 KB
testcase_27 AC 507 ms
126,960 KB
testcase_28 AC 490 ms
128,676 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[] lArr = new int[m];
        int[] rArr = new int[m];
        for (int i = 0; i < m; i++) {
            lArr[i] = sc.nextInt();
            rArr[i] = sc.nextInt();
        }
        long[][] dp = new long[k + 1][n + 2];
        Arrays.fill(dp[0], 1);
        dp[0][0] = 0;
        dp[0][n + 1] = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 0; j < m; j++) {
                long amount = (dp[i - 1][rArr[j]] - dp[i - 1][lArr[j] - 1] + MOD) % MOD;
                dp[i][lArr[j]] += amount;
                dp[i][lArr[j]] %= MOD;
                dp[i][rArr[j] + 1] += MOD - amount;
                dp[i][rArr[j] + 1] %= MOD;
            }
            for (int j = 1; j <= n + 1; j++) {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
            for (int j = 1; j <= n + 1; j++) {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
        }
        long ans = (dp[k][n] - dp[k][n - 1] + MOD) % MOD;
        System.out.println(ans);
    }
}
0