結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-01 22:01:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,626 bytes |
| コンパイル時間 | 1,689 ms |
| コンパイル使用メモリ | 171,084 KB |
| 実行使用メモリ | 5,764 KB |
| 最終ジャッジ日時 | 2024-12-25 07:53:46 |
| 合計ジャッジ時間 | 4,432 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 RE * 8 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
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 a,b;cin >> a >> b;
const int cmx=100000;
vector<ll> dv(cmx+1),dr(cmx+1);
dv[0]=1,dr[0]=1;
for(int i=0;i<n;i++){
vector<ll> tv(cmx+1);
for(int j=0;j<=cmx;j++){
if(dv[j]==0){
continue;
}
(tv[j]+=dv[j])%=mod;
if(j+v[i]<=cmx){
(tv[j+v[i]]+=dv[j])%=mod;
}
}
for(int j=0;j<=cmx;j++){
dv[j]=tv[j];
}
}
for(int i=0;i<m;i++){
vector<ll> tr(cmx+1);
for(int j=0;j<=cmx;j++){
if(dr[j]==0){
continue;
}
(tr[j]+=dr[j])%=mod;
if(j+v[i]<=cmx){
(tr[j+r[i]]+=dr[j])%=mod;
}
}
for(int j=0;j<=cmx;j++){
dr[j]=tr[j];
}
}
vector<ll> sv(cmx+1);
for(int i=1;i<=cmx;i++){
(sv[i]=sv[i-1]+dv[i])%=mod;
}
ll ans=0;
for(int i=1;i<=cmx;i++){
(ans+=(sv[min(cmx,i*b)]-sv[min(cmx,i*a-1)]+mod)%mod*dr[i]%mod)%=mod;
}
cout << ans << endl;
}