結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
mot
|
| 提出日時 | 2020-05-01 22:21:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,068 bytes |
| コンパイル時間 | 787 ms |
| コンパイル使用メモリ | 85,024 KB |
| 実行使用メモリ | 159,308 KB |
| 最終ジャッジ日時 | 2024-12-25 12:39:56 |
| 合計ジャッジ時間 | 5,794 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 3 RE * 1 |
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
ll VDP[105][100005];
ll RDP[105][100005];
int main() {
int N, M;
cin>>N>>M;
vector<ll> 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 A, B;
cin>>A>>B;
VDP[0][V[0]] = 1;
RDP[0][R[0]] = 1;
for(int i=1;i<N;++i){
for(int j=1;j<=100000;++j){
if(V[i]<=j){
if(V[i]==j){
VDP[i][j] = VDP[i-1][j] + 1;
}
else{
VDP[i][j] = VDP[i-1][j] + VDP[i-1][j-V[i]];
}
}
else{
VDP[i][j] = VDP[i-1][j];
}
VDP[i][j] %= mod;
}
}
for(int i=1;i<M;++i){
for(int j=1;j<=100000;++j){
if(R[i]<=j){
if(R[i]==j){
RDP[i][j] = RDP[i-1][j] + 1;
}
else{
RDP[i][j] = RDP[i-1][j] + RDP[i-1][j-R[i]];
}
}
else{
RDP[i][j] = RDP[i-1][j];
}
RDP[i][j] %= mod;
}
}
for(int i=1;i<100003;++i){
VDP[N-1][i] += VDP[N-1][i-1];
//RDP[i] += RDP[i-1];
}
/**
for(int i=0;i<N;++i){
for(int j=0;j<100;++j){
cout<<VDP[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
**/
ll ans = 0;
for(int i=1;i<=100000;++i){
if(i*A>100000) break;
if(i*B>100000){
ans += ((VDP[N-1][100002] - VDP[N-1][i*A-1]) * RDP[M-1][i]) % mod;
ans %= mod;
}
else{
ans += ((VDP[N-1][i*B] - VDP[N-1][i*A-1]) * RDP[M-1][i]) % mod;
ans %= mod;
}
}
cout<<ans<<endl;
}
mot