結果

問題 No.1043 直列大学
ユーザー hoktohokto
提出日時 2020-05-02 17:24:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 174,376 KB
実行使用メモリ 162,544 KB
最終ジャッジ日時 2023-08-24 12:43:12
合計ジャッジ時間 6,239 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 53 ms
43,976 KB
testcase_10 AC 77 ms
61,652 KB
testcase_11 AC 169 ms
136,232 KB
testcase_12 AC 199 ms
162,544 KB
testcase_13 AC 146 ms
116,956 KB
testcase_14 AC 159 ms
128,212 KB
testcase_15 AC 184 ms
151,852 KB
testcase_16 AC 150 ms
121,076 KB
testcase_17 AC 83 ms
66,948 KB
testcase_18 AC 85 ms
68,688 KB
testcase_19 AC 137 ms
112,156 KB
testcase_20 AC 78 ms
64,288 KB
testcase_21 AC 121 ms
98,924 KB
testcase_22 AC 126 ms
103,600 KB
testcase_23 AC 193 ms
159,528 KB
testcase_24 AC 97 ms
81,184 KB
testcase_25 AC 136 ms
111,316 KB
testcase_26 AC 158 ms
128,516 KB
testcase_27 AC 44 ms
36,792 KB
testcase_28 AC 136 ms
109,112 KB
testcase_29 AC 16 ms
14,020 KB
testcase_30 AC 94 ms
77,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define rep(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007
#define MAX_VR 1000
#define ll long long int
using namespace std;
int main()
{
	ll N,M;
	cin>>N>>M;
	vector<ll> V(N);
	vector<ll> R(M);
	sort(V.begin(),V.end());
	sort(R.begin(),R.end());
	rep(i,N) cin>>V[i];
	rep(i,M) cin>>R[i];
	ll A,B;
	cin>>A>>B;
	vector<vector<ll>> dp_v(N+1,vector<ll>(N*MAX_VR+1,0));
	vector<vector<ll>> dp_r(M+1,vector<ll>(M*MAX_VR+1,0));
	dp_v[0][0]=1;
	dp_r[0][0]=1;
	rep(i,N)
	{
		for(ll j=N*MAX_VR-V[i];j>=0;j--)
		{
			dp_v[i+1][j]+=dp_v[i][j];
			dp_v[i+1][j]%=MOD;
			dp_v[i+1][j+V[i]]+=dp_v[i][j];
			dp_v[i+1][j+V[i]]%=MOD;
		}
	}

	rep(i,M)
	{
		for(ll j=M*MAX_VR-R[i];j>=0;j--)
		{
			dp_r[i+1][j]+=dp_r[i][j];
			dp_r[i+1][j]%=MOD;
			dp_r[i+1][j+R[i]]+=dp_r[i][j];
			dp_r[i+1][j+R[i]]%=MOD;
		}
	}

	vector<ll> alloc(N*MAX_VR+2,0);
	rep(i,N*MAX_VR+1)
	{
		alloc[i+1]=alloc[i]+dp_v[N][i];
		alloc[i+1]%=MOD;
	}
	ll ans=0;
	for(ll i=1;i<=M*MAX_VR;i++)
	{
		ll max=B*i;
		ll min=A*i;
		if(min>N*MAX_VR)break;
		if(max>N*MAX_VR)max=N*MAX_VR;
		ans+=((alloc[max+1]-alloc[min]+MOD)%MOD)*dp_r[M][i];
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0