結果

問題 No.801 エレベーター
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-14 00:33:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,099 ms / 2,000 ms
コード長 1,046 bytes
コンパイル時間 2,833 ms
コンパイル使用メモリ 77,480 KB
実行使用メモリ 170,588 KB
最終ジャッジ日時 2023-10-19 17:19:46
合計ジャッジ時間 23,299 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,240 KB
testcase_01 AC 130 ms
57,516 KB
testcase_02 AC 135 ms
57,460 KB
testcase_03 AC 213 ms
59,908 KB
testcase_04 AC 218 ms
60,216 KB
testcase_05 AC 209 ms
59,788 KB
testcase_06 AC 209 ms
59,820 KB
testcase_07 AC 210 ms
60,000 KB
testcase_08 AC 210 ms
59,920 KB
testcase_09 AC 211 ms
59,748 KB
testcase_10 AC 213 ms
60,072 KB
testcase_11 AC 212 ms
59,800 KB
testcase_12 AC 212 ms
59,760 KB
testcase_13 AC 1,099 ms
167,524 KB
testcase_14 AC 1,086 ms
169,016 KB
testcase_15 AC 1,086 ms
168,324 KB
testcase_16 AC 1,063 ms
168,648 KB
testcase_17 AC 1,061 ms
169,956 KB
testcase_18 AC 1,040 ms
169,852 KB
testcase_19 AC 1,048 ms
170,260 KB
testcase_20 AC 1,085 ms
170,260 KB
testcase_21 AC 1,057 ms
170,588 KB
testcase_22 AC 1,080 ms
170,260 KB
testcase_23 AC 1,044 ms
170,004 KB
testcase_24 AC 1,044 ms
169,808 KB
testcase_25 AC 1,048 ms
170,208 KB
testcase_26 AC 1,013 ms
168,480 KB
testcase_27 AC 1,068 ms
170,508 KB
testcase_28 AC 903 ms
168,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long MOD = (long)Math.pow(10, 9) + 7;
    int n = sc.nextInt();
    int m = sc.nextInt();
    int k = sc.nextInt();
    int[] L = new int[m];
    int[] R = new int[m];
    for(int i = 0; i < m; i++) {
      L[i] = sc.nextInt();
      R[i] = sc.nextInt();
    }
    long[][] dp = new long[k + 1][n + 1];
    dp[0][1] = 1;
    for(int i = 1; i < k + 1; i++) {
      long[] rui = new long[n + 1];
      for(int j = 1; j < n + 1; j++) {
        rui[j] = (rui[j - 1] + dp[i - 1][j]) % MOD;
      }
      long[] imos = new long[n + 1];
      for(int j = 0; j < m; j++) {
        long t = (MOD + rui[R[j]] - rui[L[j] - 1]) % MOD;
        imos[L[j]] = (imos[L[j]] + t) % MOD;
        if(R[j] < n) imos[R[j] + 1] = (MOD + imos[R[j] + 1] - t) % MOD;
      }
      for(int j = 1; j < n + 1; j++) {
        imos[j] = (imos[j - 1] + imos[j]) % MOD;
        dp[i][j] = imos[j];
      }
    }
    System.out.println(dp[k][n]);
  }
}
0