結果

問題 No.1043 直列大学
ユーザー mamimume____momamimume____mo
提出日時 2020-05-23 15:27:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,600 bytes
コンパイル時間 999 ms
コンパイル使用メモリ 97,820 KB
実行使用メモリ 162,076 KB
最終ジャッジ日時 2024-04-16 23:09:22
合計ジャッジ時間 12,302 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
8,700 KB
testcase_01 AC 7 ms
7,140 KB
testcase_02 AC 16 ms
13,480 KB
testcase_03 AC 7 ms
7,276 KB
testcase_04 AC 7 ms
7,396 KB
testcase_05 AC 7 ms
7,096 KB
testcase_06 AC 7 ms
7,144 KB
testcase_07 AC 11 ms
10,244 KB
testcase_08 AC 11 ms
10,244 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 AC 179 ms
143,292 KB
testcase_15 RE -
testcase_16 AC 175 ms
140,204 KB
testcase_17 AC 131 ms
103,500 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 92 ms
71,268 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,m;
	cin >> n >> m;
	vector<ll> v(n);
	vector<ll> r(m);
	for(int i = 0;i < n;i++)cin >> v[i];
	for(int i = 0;i < m;i++)cin >> r[i];

	vector<vector<ll>> dpv(n+1,vector<ll>(100000,0));
	dpv[0][0] = 1;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= 100000;j++){
			if(j+v[i] <= 100000){
				dpv[i+1][j+v[i]] += dpv[i][j];
				dpv[i+1][j+v[i]] %= MOD;
			}
			dpv[i+1][j] += dpv[i][j];
			dpv[i+1][j] %= MOD;
		}
	}

	vector<vector<ll>> dpr(m+1,vector<ll>(100000,0));
	dpr[0][0] = 1;
	for(int i = 0;i < m;i++){
		for(int j = 0;j <= 100000;j++){
			if(j+r[i] <= 100000){
				dpr[i+1][j+r[i]] += dpr[i][j];
				dpr[i+1][j+r[i]] %= MOD;
			}
			dpr[i+1][j] += dpr[i][j];
			dpr[i+1][j] %= MOD;
		}
	}

	ll a,b;
	cin >> a >> b;

	vector<ll> v_accum(100001);
	for(int i = 1;i <= 100000;i++){
		v_accum[i] = dpv[n][i];
	}
	for(int i = 0;i <= 99999;i++){
		v_accum[i+1] = v_accum[i+1] + v_accum[i];
		v_accum[i+1] %= MOD;
	}

	ll ans = 0;
	for(int i = 1;i <= 100000;i++){
		//a*i以上b*i以下の個数.
		if(a * i > 100000)break;
		
		ll cnt = (v_accum[min(b*i,100000LL)] - v_accum[a*i-1] + MOD) % MOD;
		ans += cnt * dpr[n][i] % MOD;
	}

	cout << ans << endl;
}
0