結果

問題 No.1043 直列大学
ユーザー tentententen
提出日時 2020-12-03 11:18:38
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,317 bytes
コンパイル時間 2,420 ms
コンパイル使用メモリ 73,828 KB
実行使用メモリ 58,816 KB
最終ジャッジ日時 2023-10-11 20:26:43
合計ジャッジ時間 9,086 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
57,924 KB
testcase_01 AC 138 ms
57,704 KB
testcase_02 AC 152 ms
57,892 KB
testcase_03 AC 139 ms
58,128 KB
testcase_04 AC 141 ms
57,904 KB
testcase_05 AC 139 ms
57,812 KB
testcase_06 AC 140 ms
57,760 KB
testcase_07 AC 150 ms
57,792 KB
testcase_08 AC 150 ms
57,896 KB
testcase_09 AC 175 ms
58,376 KB
testcase_10 AC 184 ms
58,116 KB
testcase_11 AC 185 ms
58,136 KB
testcase_12 RE -
testcase_13 AC 183 ms
58,468 KB
testcase_14 AC 186 ms
58,736 KB
testcase_15 AC 187 ms
58,568 KB
testcase_16 AC 182 ms
58,092 KB
testcase_17 AC 177 ms
58,260 KB
testcase_18 AC 179 ms
56,000 KB
testcase_19 AC 181 ms
58,312 KB
testcase_20 AC 174 ms
58,168 KB
testcase_21 AC 181 ms
58,816 KB
testcase_22 AC 182 ms
58,380 KB
testcase_23 AC 188 ms
58,108 KB
testcase_24 AC 178 ms
58,628 KB
testcase_25 AC 182 ms
58,592 KB
testcase_26 AC 183 ms
58,088 KB
testcase_27 AC 178 ms
58,408 KB
testcase_28 AC 193 ms
58,476 KB
testcase_29 AC 170 ms
58,044 KB
testcase_30 AC 184 ms
58,384 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++) {
            ans += (sums[Math.min(MAX - 1, i * b)] - sums[i * a - 1] + MOD) % MOD * resists[i] % MOD;
            ans %= MOD;
        }
        System.out.println(ans);
    }
}
0