結果

問題 No.801 エレベーター
ユーザー tentententen
提出日時 2022-08-25 09:26:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 2,098 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 78,544 KB
実行使用メモリ 42,688 KB
最終ジャッジ日時 2024-04-20 19:28:54
合計ジャッジ時間 9,404 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
37,248 KB
testcase_01 AC 47 ms
36,936 KB
testcase_02 AC 52 ms
36,948 KB
testcase_03 AC 80 ms
38,084 KB
testcase_04 AC 80 ms
38,024 KB
testcase_05 AC 82 ms
38,536 KB
testcase_06 AC 81 ms
38,132 KB
testcase_07 AC 80 ms
38,184 KB
testcase_08 AC 80 ms
38,116 KB
testcase_09 AC 79 ms
38,652 KB
testcase_10 AC 78 ms
38,540 KB
testcase_11 AC 84 ms
38,600 KB
testcase_12 AC 82 ms
38,396 KB
testcase_13 AC 308 ms
40,732 KB
testcase_14 AC 356 ms
42,688 KB
testcase_15 AC 355 ms
41,956 KB
testcase_16 AC 352 ms
41,820 KB
testcase_17 AC 344 ms
41,028 KB
testcase_18 AC 354 ms
41,960 KB
testcase_19 AC 315 ms
40,784 KB
testcase_20 AC 346 ms
42,004 KB
testcase_21 AC 341 ms
42,032 KB
testcase_22 AC 311 ms
40,640 KB
testcase_23 AC 333 ms
41,948 KB
testcase_24 AC 344 ms
42,108 KB
testcase_25 AC 336 ms
40,800 KB
testcase_26 AC 356 ms
40,832 KB
testcase_27 AC 354 ms
40,808 KB
testcase_28 AC 341 ms
42,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[] current = new int[n + 2];
        int[] next = new int[n + 2];
        Arrays.fill(current, 1);
        current[0] = 0;
        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();
        }
        while (k-- > 0) {
            for (int i = 0; i < m; i++) {
                int x = (current[rights[i]] - current[lefts[i] - 1] + MOD) % MOD;
                next[lefts[i]] += x;
                next[lefts[i]] %= MOD;
                next[rights[i] + 1] += MOD - x;
                next[rights[i] + 1] %= MOD;
            }
            for (int i = 1; i <= n; i++) {
                next[i] += next[i - 1];
                next[i] %= MOD;
            }
            for (int i = 1; i <= n; i++) {
                next[i] += next[i - 1];
                next[i] %= MOD;
            }
            int[] tmp = next;
            next = current;
            current = tmp;
            Arrays.fill(next, 0);
        }
        System.out.println((current[n] - current[n - 1] + MOD) % MOD);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0