結果

問題 No.1043 直列大学
ユーザー joybeeeejoybeeee
提出日時 2020-05-13 17:32:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,362 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 74,000 KB
実行使用メモリ 58,376 KB
最終ジャッジ日時 2023-10-12 17:01:16
合計ジャッジ時間 9,092 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
56,684 KB
testcase_01 AC 145 ms
55,904 KB
testcase_02 AC 167 ms
56,712 KB
testcase_03 AC 145 ms
55,960 KB
testcase_04 AC 146 ms
56,040 KB
testcase_05 AC 147 ms
55,880 KB
testcase_06 AC 145 ms
55,788 KB
testcase_07 AC 153 ms
56,332 KB
testcase_08 AC 152 ms
56,608 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 191 ms
56,768 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 182 ms
56,260 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 171 ms
56,252 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int mod = 1000000007;
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] vArr = new int[n];
      int[] rArr = new int[m];

      for(int i = 0; i < n; i++)
        vArr[i] = sc.nextInt();
      for(int i = 0; i < m; i++)
        rArr[i] = sc.nextInt();

      int a = sc.nextInt();
      int b = sc.nextInt();
      
      int[] dpV = new int[101010]; dpV[0] = 1;
      int[] dpR = new int[101010]; dpR[0] = 1;

      for(int i = 0; i < n; i++)
        for(int j = dpV.length - 1; j > 0; j--) {
          if(j - vArr[i] < 0) continue;
          dpV[j] += dpV[j - vArr[i]];
        }

      for(int i = 0; i < m; i++)
        for(int j = dpR.length - 1; j > 0; j--) {
          if(j - rArr[i] < 0) continue;
          dpR[j] += dpR[j - rArr[i]];
        }

      for(int i = 1; i < dpV.length; i++)
        dpV[i] = (dpV[i] + dpV[i-1]) % mod;

      long cnt = 0L;
      for(int r = 1; r < dpR.length; r++) {
        if(dpR[r] == 0) continue;
        int leftV = a * r;
        int rightV = b * r;
        if(leftV > dpV.length - 1) continue;
        rightV = Math.min(rightV, dpV.length - 1);
        cnt = cnt + (long)dpR[r] * (dpV[rightV] - dpV[leftV - 1]) % mod;
      }
      System.out.println(cnt);
  }
}
0