結果

問題 No.1043 直列大学
ユーザー 👑 platinumplatinum
提出日時 2020-05-01 23:04:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,015 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 166,116 KB
実行使用メモリ 90,416 KB
最終ジャッジ日時 2023-08-26 15:42:39
合計ジャッジ時間 4,001 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
90,068 KB
testcase_01 AC 25 ms
90,084 KB
testcase_02 AC 26 ms
90,084 KB
testcase_03 AC 27 ms
90,072 KB
testcase_04 AC 26 ms
90,208 KB
testcase_05 AC 25 ms
90,144 KB
testcase_06 AC 26 ms
90,072 KB
testcase_07 AC 26 ms
90,124 KB
testcase_08 AC 26 ms
90,112 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 45 ms
90,308 KB
testcase_15 AC 48 ms
90,088 KB
testcase_16 AC 46 ms
90,084 KB
testcase_17 AC 39 ms
90,224 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 35 ms
90,312 KB
testcase_28 WA -
testcase_29 AC 30 ms
90,200 KB
testcase_30 AC 38 ms
90,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int Max_Sum=100010;
const int mod=1e9+7;

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> V(N), R(M);
	rep(i,N) cin >> V[i];
	rep(i,M) cin >> R[i];
	int A, B;
	cin >> A >> B;
	int dpV[110][Max_Sum]={0}, dpR[110][Max_Sum]={0};
	dpV[0][0]=1, dpR[0][0]=1;
	rep(i,N){
		rep(j,Max_Sum){
			dpV[i+1][j]+=dpV[i][j];
			if(j>=V[i]) dpV[i+1][j]+=dpV[i][j-V[i]];
			dpV[i+1][j]%mod;
		}
	}
	rep(i,M){
		rep(j,Max_Sum){
			dpR[i+1][j]+=dpR[i][j];
			if(j>=R[i]) dpR[i+1][j]+=dpR[i][j-R[i]];
			dpR[i+1][j]%mod;
		}
	}
	LL Vsum[Max_Sum]={0};
	rep(i,Max_Sum-1){
		Vsum[i+1]=Vsum[i]+dpV[N][i+1];
		Vsum[i+1]%=mod;
	}
	LL ans=0;
	for(LL R=1; R<Max_Sum; R++){
		LL num=dpR[M][R];
		if(num==0) continue;
		if(R*A>Max_Sum) continue;
		if(R*B<Max_Sum) ans+=num*(Vsum[R*B]-Vsum[R*A-1]);
		else ans+=num*(Vsum[Max_Sum-1]-Vsum[R*A-1]);
		ans%=mod;
	}
	cout << ans << endl;

	return 0;
}
0