結果

問題 No.1043 直列大学
ユーザー hoktohokto
提出日時 2020-05-02 16:49:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,086 bytes
コンパイル時間 2,218 ms
コンパイル使用メモリ 208,152 KB
実行使用メモリ 159,564 KB
最終ジャッジ日時 2023-08-28 22:29:58
合計ジャッジ時間 6,518 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 148 ms
136,292 KB
testcase_12 TLE -
testcase_13 AC 132 ms
117,280 KB
testcase_14 AC 143 ms
128,020 KB
testcase_15 AC 168 ms
151,832 KB
testcase_16 AC 134 ms
121,208 KB
testcase_17 AC 74 ms
66,680 KB
testcase_18 WA -
testcase_19 AC 122 ms
112,520 KB
testcase_20 AC 72 ms
64,420 KB
testcase_21 AC 108 ms
99,216 KB
testcase_22 AC 113 ms
103,784 KB
testcase_23 AC 175 ms
159,564 KB
testcase_24 AC 89 ms
81,172 KB
testcase_25 AC 122 ms
111,520 KB
testcase_26 AC 141 ms
128,856 KB
testcase_27 AC 41 ms
36,852 KB
testcase_28 AC 122 ms
109,352 KB
testcase_29 AC 14 ms
14,216 KB
testcase_30 AC 87 ms
78,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define MAX_VR 1000
#define ll long long int
using namespace std;
int main()
{
	int N,M;
	cin>>N>>M;
	vector<int> V(N);
	vector<int> R(M);
	sort(V.begin(),V.end());
	sort(R.begin(),R.end());
	rep(i,N) cin>>V[i];
	rep(i,M) cin>>R[i];
	int 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(int 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(int 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(int i=1;i<=M*MAX_VR;i++)
	{
		int max=B*i;
		int 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