結果

問題 No.1043 直列大学
ユーザー KKT89KKT89
提出日時 2020-05-01 22:10:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,367 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 94,844 KB
実行使用メモリ 6,860 KB
最終ジャッジ日時 2023-08-26 14:08:32
合計ジャッジ時間 3,723 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,632 KB
testcase_01 AC 7 ms
6,632 KB
testcase_02 AC 10 ms
6,676 KB
testcase_03 AC 7 ms
6,692 KB
testcase_04 AC 7 ms
6,632 KB
testcase_05 AC 7 ms
6,760 KB
testcase_06 AC 7 ms
6,644 KB
testcase_07 AC 8 ms
6,612 KB
testcase_08 AC 8 ms
6,704 KB
testcase_09 AC 37 ms
6,652 KB
testcase_10 AC 43 ms
6,680 KB
testcase_11 WA -
testcase_12 AC 68 ms
6,668 KB
testcase_13 WA -
testcase_14 AC 61 ms
6,676 KB
testcase_15 AC 66 ms
6,756 KB
testcase_16 AC 60 ms
6,656 KB
testcase_17 AC 45 ms
6,860 KB
testcase_18 AC 45 ms
6,664 KB
testcase_19 AC 56 ms
6,676 KB
testcase_20 AC 44 ms
6,644 KB
testcase_21 AC 52 ms
6,696 KB
testcase_22 AC 55 ms
6,680 KB
testcase_23 AC 68 ms
6,656 KB
testcase_24 AC 49 ms
6,660 KB
testcase_25 AC 57 ms
6,660 KB
testcase_26 AC 61 ms
6,696 KB
testcase_27 AC 33 ms
6,720 KB
testcase_28 AC 57 ms
6,836 KB
testcase_29 AC 22 ms
6,644 KB
testcase_30 AC 44 ms
6,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <math.h>
using namespace std;

typedef long long ll;

constexpr ll mod=1e9+7;

ll dp[2][101100];
ll dp2[2][101101];

int main(){
    cin.tie(nullptr);
    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 pre=0;
    int nex=1;
    dp[0][0]=1;
    int a,b; cin >> a >> b;
    for(int i=0;i<n;i++){
        for(int j=0;j<100000;j++){
            (dp[nex][j+v[i]]+=dp[pre][j])%=mod;
            (dp[nex][j]+=dp[pre][j])%=mod;
            dp[pre][j]=0;
        }
        swap(pre,nex);
    }
    int ppre=0;
    int nnex=1;
    dp2[0][0]=1;
    for(int i=0;i<m;i++){
        for(int j=0;j<100000;j++){
            (dp2[nnex][j+r[i]]+=dp2[ppre][j])%=mod;
            (dp2[nnex][j]+=dp2[ppre][j])%=mod;
            dp2[ppre][j]=0;
        }
        swap(nnex,ppre);
    }
    for(int i=0;i<100100;i++){
        (dp[pre][i+1]+=dp[pre][i])%=mod;
    }
    ll res=0;
    for(int i=1;i<=100000;i++){
        if(dp2[ppre][i]==0)continue;
        ll aa=min((ll)a*i,100000LL);
        ll bb=min((ll)b*i,100000LL);
        (res+=(dp[pre][bb]-dp[pre][aa-1])%mod*dp2[ppre][i])%=mod;
    }
    printf("%lld\n",res);
}
0