結果

問題 No.1043 直列大学
ユーザー RubikunRubikun
提出日時 2020-05-01 21:38:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 1,552 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 168,312 KB
実行使用メモリ 136,172 KB
最終ジャッジ日時 2023-08-24 05:40:12
合計ジャッジ時間 3,701 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,920 KB
testcase_01 AC 3 ms
5,460 KB
testcase_02 AC 4 ms
10,252 KB
testcase_03 AC 3 ms
5,464 KB
testcase_04 AC 3 ms
5,620 KB
testcase_05 AC 4 ms
5,520 KB
testcase_06 AC 4 ms
5,452 KB
testcase_07 AC 4 ms
9,512 KB
testcase_08 AC 4 ms
9,540 KB
testcase_09 AC 29 ms
78,548 KB
testcase_10 AC 35 ms
86,776 KB
testcase_11 AC 64 ms
110,048 KB
testcase_12 AC 69 ms
121,924 KB
testcase_13 AC 53 ms
99,184 KB
testcase_14 AC 58 ms
112,344 KB
testcase_15 AC 65 ms
116,416 KB
testcase_16 AC 55 ms
106,960 KB
testcase_17 AC 36 ms
89,408 KB
testcase_18 AC 36 ms
84,080 KB
testcase_19 AC 51 ms
96,580 KB
testcase_20 AC 35 ms
88,572 KB
testcase_21 AC 47 ms
90,008 KB
testcase_22 AC 49 ms
92,392 KB
testcase_23 AC 68 ms
136,172 KB
testcase_24 AC 42 ms
105,920 KB
testcase_25 AC 52 ms
117,664 KB
testcase_26 AC 57 ms
121,068 KB
testcase_27 AC 23 ms
69,152 KB
testcase_28 AC 51 ms
120,992 KB
testcase_29 AC 13 ms
42,692 KB
testcase_30 AC 38 ms
99,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0