結果

問題 No.801 エレベーター
ユーザー tentententen
提出日時 2023-01-31 16:17:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 2,600 bytes
コンパイル時間 4,285 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 55,924 KB
最終ジャッジ日時 2023-09-13 08:53:15
合計ジャッジ時間 11,855 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,452 KB
testcase_01 AC 41 ms
49,380 KB
testcase_02 AC 42 ms
49,280 KB
testcase_03 AC 76 ms
51,708 KB
testcase_04 AC 79 ms
52,300 KB
testcase_05 AC 78 ms
51,960 KB
testcase_06 AC 77 ms
51,964 KB
testcase_07 AC 79 ms
51,584 KB
testcase_08 AC 80 ms
52,120 KB
testcase_09 AC 76 ms
51,880 KB
testcase_10 AC 77 ms
52,244 KB
testcase_11 AC 76 ms
52,048 KB
testcase_12 AC 77 ms
52,116 KB
testcase_13 AC 312 ms
55,108 KB
testcase_14 AC 328 ms
55,496 KB
testcase_15 AC 344 ms
55,924 KB
testcase_16 AC 322 ms
55,216 KB
testcase_17 AC 318 ms
55,480 KB
testcase_18 AC 323 ms
54,924 KB
testcase_19 AC 336 ms
55,716 KB
testcase_20 AC 324 ms
55,096 KB
testcase_21 AC 317 ms
55,064 KB
testcase_22 AC 332 ms
55,460 KB
testcase_23 AC 326 ms
55,304 KB
testcase_24 AC 311 ms
54,896 KB
testcase_25 AC 304 ms
54,616 KB
testcase_26 AC 321 ms
55,164 KB
testcase_27 AC 331 ms
55,708 KB
testcase_28 AC 326 ms
54,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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[] 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[] current = new int[n + 2];
        Arrays.fill(current, 1);
        current[0] = 0;
        while (k-- > 0) {
            int[] next = new int[n + 2];
            for (int i = 0; i < m; i++) {
                int size = (current[rights[i]] - current[lefts[i] - 1] + MOD) % MOD;
                next[lefts[i]] += size;
                next[lefts[i]] %= MOD;
                next[rights[i] + 1] += MOD - size;
                next[rights[i] + 1] %= MOD;
            }
            for (int i = 1; i < next.length; i++) {
                next[i] += next[i - 1];
                next[i] %= MOD;
            }
            for (int i = 1; i < next.length; i++) {
                next[i] += next[i - 1];
                next[i] %= MOD;
            }
            current = next;
        }
        System.out.println((current[n] - current[n - 1] + MOD) % MOD);
    }
}

class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0