結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2020-05-01 21:38:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 2,000 ms |
| コード長 | 1,552 bytes |
| コンパイル時間 | 1,714 ms |
| コンパイル使用メモリ | 170,036 KB |
| 実行使用メモリ | 139,368 KB |
| 最終ジャッジ日時 | 2024-12-22 19:24:11 |
| 合計ジャッジ時間 | 3,844 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005;
const ll INF=1LL<<60;
ll dp[105][MAX],dp2[105][MAX];
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int N,M;cin>>N>>M;
vector<int> A(N),B(M);
for(int i=0;i<N;i++) cin>>A[i];
for(int i=0;i<M;i++) cin>>B[i];
ll C,D;cin>>C>>D;
dp[0][0]=1;
dp2[0][0]=1;
for(int i=0;i<N;i++){
for(int j=0;j<=i*1000;j++){
dp[i+1][j+A[i]]+=dp[i][j];
dp[i+1][j]+=dp[i][j];
dp[i+1][j+A[i]]%=mod;
dp[i+1][j]%=mod;
}
}
for(int i=0;i<M;i++){
for(int j=0;j<=i*1000;j++){
dp2[i+1][j+B[i]]+=dp2[i][j];
dp2[i+1][j]+=dp2[i][j];
dp2[i+1][j+B[i]]%=mod;
dp2[i+1][j]%=mod;
}
}
for(int j=1;j<=100000;j++){
dp[N][j]+=dp[N][j-1];
dp[N][j]%=mod;
}
ll ans=0;
for(int j=1;j<=100000;j++){
ll sum=(dp[N][min(100000LL,D*j)]-dp[N][min(100000LL,C*j-1)]+mod)%mod*dp2[M][j];
ans+=sum+mod;
ans%=mod;
}
cout<<ans<<endl;
}
Rubikun