結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-02 16:49:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,086 bytes |
| コンパイル時間 | 2,629 ms |
| コンパイル使用メモリ | 203,800 KB |
| 最終ジャッジ日時 | 2025-01-10 05:58:27 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 14 |
ソースコード
#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;
}