結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
joybeeee
|
| 提出日時 | 2020-05-13 20:19:15 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 458 ms / 2,000 ms |
| コード長 | 1,422 bytes |
| コンパイル時間 | 2,362 ms |
| コンパイル使用メモリ | 76,796 KB |
| 実行使用メモリ | 43,828 KB |
| 最終ジャッジ日時 | 2024-12-22 20:07:46 |
| 合計ジャッジ時間 | 13,577 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
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();
long a = sc.nextInt();
long b = sc.nextInt();
long[] dpV = new long[101010]; dpV[0] = 1L;
long[] dpR = new long[101010]; dpR[0] = 1L;
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] + dpV[j - vArr[i]]) % mod;
}
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] + dpR[j - rArr[i]]) % mod;
}
for(int i = 1; i < dpV.length; i++)
dpV[i] = (dpV[i] + dpV[i-1]);
long cnt = 0L;
for(int r = 1; r < dpR.length; r++) {
if(dpR[r] == 0) continue;
long leftV = a * r;
long rightV = b * r;
if(leftV > dpV.length - 1) continue;
rightV = Math.min(rightV, dpV.length - 1);
cnt = cnt + (long)dpR[r] * ((dpV[(int)rightV] - dpV[(int)leftV - 1]) % mod) % mod;
}
System.out.println(cnt % mod);
}
}
joybeeee