結果

問題 No.1043 直列大学
ユーザー 沙耶花沙耶花
提出日時 2020-05-01 21:46:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,306 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 204,812 KB
実行使用メモリ 82,316 KB
最終ジャッジ日時 2023-08-24 05:40:50
合計ジャッジ時間 4,745 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,720 KB
testcase_01 AC 4 ms
4,884 KB
testcase_02 AC 8 ms
8,256 KB
testcase_03 AC 5 ms
5,280 KB
testcase_04 AC 4 ms
5,068 KB
testcase_05 AC 5 ms
4,932 KB
testcase_06 AC 5 ms
5,056 KB
testcase_07 AC 6 ms
6,632 KB
testcase_08 AC 6 ms
6,576 KB
testcase_09 AC 44 ms
43,452 KB
testcase_10 AC 50 ms
51,272 KB
testcase_11 AC 75 ms
76,000 KB
testcase_12 AC 95 ms
82,316 KB
testcase_13 AC 78 ms
69,228 KB
testcase_14 AC 81 ms
72,952 KB
testcase_15 AC 91 ms
79,740 KB
testcase_16 AC 81 ms
71,340 KB
testcase_17 AC 57 ms
53,108 KB
testcase_18 AC 56 ms
53,088 KB
testcase_19 AC 76 ms
67,928 KB
testcase_20 AC 55 ms
52,276 KB
testcase_21 AC 69 ms
62,584 KB
testcase_22 AC 73 ms
65,160 KB
testcase_23 AC 94 ms
81,708 KB
testcase_24 AC 62 ms
58,304 KB
testcase_25 AC 76 ms
68,352 KB
testcase_26 AC 82 ms
73,192 KB
testcase_27 AC 38 ms
37,176 KB
testcase_28 AC 71 ms
67,668 KB
testcase_29 AC 23 ms
23,732 KB
testcase_30 AC 60 ms
51,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> V(N),R(M);
	
	for(int i=0;i<N;i++)cin>>V[i];
	for(int i=0;i<M;i++)cin>>R[i];
	
	int t = 100001;
	
	vector<vector<int>> dp1(N+1,vector<int>(t,0)),dp2(M+1,vector<int>(t,0));
	dp1[0][0]=1,dp2[0][0]=1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<t;j++){
			if(dp1[i][j]==0)continue;
			dp1[i+1][j] = mod(dp1[i+1][j]+dp1[i][j]);
			dp1[i+1][j+V[i]] = mod(dp1[i+1][j+V[i]]+dp1[i][j]);
		}
	}
	
	for(int i=0;i<M;i++){
		for(int j=0;j<t;j++){
			if(dp2[i][j]==0)continue;
			dp2[i+1][j] = mod(dp2[i+1][j]+dp2[i][j]);
			dp2[i+1][j+R[i]] = mod(dp2[i+1][j+R[i]] + dp2[i][j]);
		}
	}
	
	for(int i=1;i<t;i++){
		dp1.back()[i] = mod(dp1.back()[i] + dp1.back()[i-1]);
	}
	
	/*
	
	for(int i=0;i<10;i++){
		cout<<dp1.back()[i]<<',';
	}
	cout<<endl;
	*/
	int ans = 0;
	int A,B;
	cin>>A>>B;
	for(int i=1;i<t;i++){
		long long a = (long long)A*i,b = (long long)B*i;
		int temp = 0;
		if(b<t){
			temp = dp1.back()[b];
		}
		else temp=dp1.back().back();
		
		if(a-1<t){
			temp = mod(temp - dp1.back()[a-1]);
		}
		else{
			temp = 0;
		}
		
		ans = mod(ans + mod(temp * dp2.back()[i]));
	}
	
	cout<<ans<<endl;
	
	return 0;
}
0