結果

問題 No.1043 直列大学
ユーザー tentententen
提出日時 2020-12-03 11:26:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 1,487 bytes
コンパイル時間 4,558 ms
コンパイル使用メモリ 73,668 KB
実行使用メモリ 60,952 KB
最終ジャッジ日時 2023-08-24 12:54:21
合計ジャッジ時間 9,084 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
57,900 KB
testcase_01 AC 131 ms
58,032 KB
testcase_02 AC 141 ms
57,568 KB
testcase_03 AC 131 ms
57,772 KB
testcase_04 AC 129 ms
58,020 KB
testcase_05 AC 131 ms
57,900 KB
testcase_06 AC 131 ms
57,920 KB
testcase_07 AC 139 ms
58,228 KB
testcase_08 AC 140 ms
57,936 KB
testcase_09 AC 170 ms
58,688 KB
testcase_10 AC 175 ms
58,600 KB
testcase_11 AC 178 ms
58,924 KB
testcase_12 AC 189 ms
58,664 KB
testcase_13 AC 176 ms
58,672 KB
testcase_14 AC 173 ms
58,812 KB
testcase_15 AC 175 ms
58,536 KB
testcase_16 AC 175 ms
58,216 KB
testcase_17 AC 166 ms
58,432 KB
testcase_18 AC 171 ms
58,892 KB
testcase_19 AC 176 ms
58,508 KB
testcase_20 AC 165 ms
59,056 KB
testcase_21 AC 173 ms
58,320 KB
testcase_22 AC 174 ms
60,952 KB
testcase_23 AC 181 ms
60,672 KB
testcase_24 AC 171 ms
58,660 KB
testcase_25 AC 173 ms
58,192 KB
testcase_26 AC 175 ms
58,724 KB
testcase_27 AC 165 ms
58,968 KB
testcase_28 AC 181 ms
58,944 KB
testcase_29 AC 170 ms
58,652 KB
testcase_30 AC 176 ms
58,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MAX = 100 * 1000 + 1;
    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();
        long[] volts = new long[MAX];
        volts[0] = 1;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            for (int j = 1000 * i; j >= 0; j--) {
                volts[j + x] += volts[j];
                volts[j + x] %= MOD;
            }
        }
        long[] sums = new long[MAX];
        for (int i = 1; i < MAX; i++) {
            sums[i] += sums[i - 1] + volts[i];
            sums[i] %= MOD;
        }
        long[] resists = new long[MAX];
        resists[0] = 1;
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            for (int j = 1000 * i; j >= 0; j--) {
                resists[j + x] += resists[j];
                resists[j + x] %= MOD;
            }
        }
        int a = sc.nextInt();
        int b = sc.nextInt();
        long ans = 0;
        for (int i = 1; i * a < MAX; i++) {
            int idx;
            if (Integer.MAX_VALUE / i <= b) {
                idx = Integer.MAX_VALUE;
            } else {
                idx = i * b;
            }
            ans += (sums[Math.min(MAX - 1, idx)] - sums[i * a - 1] + MOD) % MOD * resists[i] % MOD;
            ans %= MOD;
        }
        System.out.println(ans);
    }
}
0