結果

問題 No.1043 直列大学
ユーザー kappybarkappybar
提出日時 2020-05-01 22:16:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 1,618 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 171,216 KB
実行使用メモリ 83,460 KB
最終ジャッジ日時 2023-08-24 05:46:23
合計ジャッジ時間 5,591 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,828 KB
testcase_01 AC 10 ms
6,224 KB
testcase_02 AC 17 ms
9,152 KB
testcase_03 AC 10 ms
6,152 KB
testcase_04 AC 10 ms
6,108 KB
testcase_05 AC 11 ms
6,300 KB
testcase_06 AC 10 ms
6,284 KB
testcase_07 AC 14 ms
7,624 KB
testcase_08 AC 13 ms
7,756 KB
testcase_09 AC 85 ms
44,344 KB
testcase_10 AC 101 ms
57,804 KB
testcase_11 AC 150 ms
78,904 KB
testcase_12 AC 161 ms
83,460 KB
testcase_13 AC 136 ms
81,444 KB
testcase_14 AC 147 ms
82,120 KB
testcase_15 AC 160 ms
80,708 KB
testcase_16 AC 142 ms
73,324 KB
testcase_17 AC 105 ms
60,224 KB
testcase_18 AC 106 ms
63,572 KB
testcase_19 AC 133 ms
80,928 KB
testcase_20 AC 103 ms
61,080 KB
testcase_21 AC 124 ms
79,032 KB
testcase_22 AC 129 ms
76,644 KB
testcase_23 AC 161 ms
82,552 KB
testcase_24 AC 118 ms
65,020 KB
testcase_25 AC 135 ms
73,608 KB
testcase_26 AC 144 ms
81,568 KB
testcase_27 AC 73 ms
51,404 KB
testcase_28 AC 132 ms
75,700 KB
testcase_29 AC 45 ms
28,840 KB
testcase_30 AC 102 ms
76,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr int MOD = 1000000007;
const int MX = 100005;

vector<ll>  count(ll n,const vector<ll>& a){
    vector<vector<ll>> dp(n+1,vector<ll>(MX,0));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        rep(j,MX){
            if(j - a[i-1] >= 0){
                dp[i][j] = (dp[i-1][j] + dp[i-1][j-a[i-1]])%MOD;
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    dp[n][0] = 0;
    return dp[n];
}

ll under(ll A,vector<ll> v,vector<ll> r){
    ll ans = 0;
    rep(i,MX){
        if(A*i >= MX) ans = (ans + (v[MX-1]*r[i])%MOD)%MOD;
        else ans = (ans + (v[A*i]*r[i])%MOD)%MOD;
    }
    return ans;
}

ll just(ll A,vector<ll> v,vector<ll> r){
    ll ans = 0;
    rep(i,MX){
        if(A*i >= MX);
        else ans = (ans + (v[A*i]*r[i])%MOD)%MOD;
    }
    return ans;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    vector<ll> r(m);
    rep(i,m) cin >> r[i];
    ll a,b;
    cin >> a >> b;
    vector<ll> V = count(n,v);
    vector<ll> R = count(m,r);
    ll C = just(a,V,R);
    /*
    rep(i,100) cout << V[i] <<" ";
    cout << endl;
    rep(i,100) cout << R[i] <<" ";
    cout << endl;
    */
    rep(i,MX-1) V[i+1] = (V[i+1] + V[i])%MOD;
    ll A = under(a,V,R);
    ll B = under(b,V,R);
    //cout << A << " "<< B << endl;
    cout << (B - A + C + MOD)%MOD << endl;
    return 0;
}
0