結果

問題 No.1043 直列大学
ユーザー hoktohokto
提出日時 2020-05-02 17:09:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,076 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 206,804 KB
実行使用メモリ 162,864 KB
最終ジャッジ日時 2023-08-28 23:23:53
合計ジャッジ時間 6,077 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 140 ms
136,284 KB
testcase_12 WA -
testcase_13 AC 125 ms
116,896 KB
testcase_14 AC 137 ms
128,160 KB
testcase_15 AC 161 ms
151,804 KB
testcase_16 AC 128 ms
121,196 KB
testcase_17 AC 72 ms
66,820 KB
testcase_18 WA -
testcase_19 AC 120 ms
112,384 KB
testcase_20 AC 69 ms
64,280 KB
testcase_21 AC 101 ms
98,796 KB
testcase_22 AC 109 ms
103,784 KB
testcase_23 AC 170 ms
159,368 KB
testcase_24 AC 86 ms
80,964 KB
testcase_25 AC 119 ms
111,380 KB
testcase_26 AC 138 ms
128,692 KB
testcase_27 AC 38 ms
36,492 KB
testcase_28 AC 119 ms
109,020 KB
testcase_29 AC 14 ms
13,892 KB
testcase_30 AC 83 ms
77,720 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+V[i]]+=dp_v[i][j];
			dp_v[i+1][j]%=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+R[i]]+=dp_r[i][j];
			dp_r[i+1][j]%=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