結果

問題 No.1043 直列大学
ユーザー hoktohokto
提出日時 2020-05-02 17:20:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,132 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 174,384 KB
実行使用メモリ 162,712 KB
最終ジャッジ日時 2023-08-28 23:42:16
合計ジャッジ時間 4,952 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 157 ms
136,336 KB
testcase_12 WA -
testcase_13 AC 135 ms
117,044 KB
testcase_14 AC 150 ms
128,000 KB
testcase_15 AC 171 ms
151,956 KB
testcase_16 AC 137 ms
121,132 KB
testcase_17 AC 76 ms
66,604 KB
testcase_18 WA -
testcase_19 AC 129 ms
112,508 KB
testcase_20 AC 75 ms
64,320 KB
testcase_21 AC 114 ms
98,992 KB
testcase_22 AC 122 ms
103,580 KB
testcase_23 AC 182 ms
159,396 KB
testcase_24 AC 91 ms
80,864 KB
testcase_25 AC 125 ms
111,348 KB
testcase_26 AC 156 ms
128,656 KB
testcase_27 AC 40 ms
36,608 KB
testcase_28 AC 130 ms
109,004 KB
testcase_29 AC 14 ms
13,976 KB
testcase_30 AC 87 ms
77,908 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];
	}
	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])*dp_r[M][i];
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0