結果

問題 No.1043 直列大学
ユーザー okok
提出日時 2020-05-01 22:46:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,377 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 83,568 KB
実行使用メモリ 4,716 KB
最終ジャッジ日時 2023-08-24 05:50:52
合計ジャッジ時間 2,892 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,412 KB
testcase_01 AC 4 ms
4,620 KB
testcase_02 AC 6 ms
4,680 KB
testcase_03 AC 4 ms
4,616 KB
testcase_04 AC 5 ms
4,576 KB
testcase_05 AC 5 ms
4,612 KB
testcase_06 AC 5 ms
4,620 KB
testcase_07 AC 5 ms
4,556 KB
testcase_08 AC 5 ms
4,396 KB
testcase_09 AC 28 ms
4,464 KB
testcase_10 AC 33 ms
4,396 KB
testcase_11 AC 48 ms
4,624 KB
testcase_12 AC 52 ms
4,680 KB
testcase_13 AC 45 ms
4,624 KB
testcase_14 AC 47 ms
4,400 KB
testcase_15 AC 51 ms
4,616 KB
testcase_16 AC 45 ms
4,412 KB
testcase_17 AC 34 ms
4,616 KB
testcase_18 AC 35 ms
4,672 KB
testcase_19 AC 43 ms
4,716 KB
testcase_20 AC 33 ms
4,560 KB
testcase_21 AC 40 ms
4,460 KB
testcase_22 AC 42 ms
4,616 KB
testcase_23 AC 52 ms
4,612 KB
testcase_24 AC 37 ms
4,672 KB
testcase_25 AC 44 ms
4,500 KB
testcase_26 AC 47 ms
4,400 KB
testcase_27 AC 24 ms
4,556 KB
testcase_28 AC 43 ms
4,616 KB
testcase_29 AC 17 ms
4,536 KB
testcase_30 AC 33 ms
4,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} ;
// } fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	constexpr int MAX = 1010 * 100;
	
	int N, M;
	int A, B;
	int ans = 0;
	vector<int> V, R;
	vector<int> Vtable(MAX);
	vector<int> Rtable(MAX);
	
	cin>>N>>M;
	
	V.resize(N);
	R.resize(M);
	
	
	for(int i = 0; i < N; i++){
		cin>>V[i];
	}
	
	for(int i = 0; i < M; i++){
		cin>>R[i];
	}
	
	cin>>A>>B;
	
	Vtable[0] = 1;
	Rtable[0] = 1;
	
	for(int i = 0; i < N; i++){
		for(int j = MAX - V[i] - 1; j >= 0; j--){
			Vtable[j+V[i]] += Vtable[j];
			Vtable[j+V[i]] %= MOD;
		}
	}
	
	for(int i = 0; i < M; i++){
		for(int j = MAX - R[i] - 1; j >= 0; j--){
			Rtable[j+R[i]] += Rtable[j];
			Rtable[j+R[i]] %= MOD;
		}
	}
	
	for(int i = 1; i < MAX; i++){
		Vtable[i] += Vtable[i-1];
		Vtable[i] %= MOD;
	}
	
	for(int i = 1; i < MAX; i++){
		int a = A * i;
		int b = B * i;
		
		a--;
		b--;
		
		a = min(MAX-2, a);
		b = min(MAX-2, b);
		
		ans += (Vtable[b+1] + MOD - Vtable[a]) % MOD  * Rtable[i] % MOD;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}
0