結果

問題 No.1043 直列大学
ユーザー Manuel1024Manuel1024
提出日時 2021-04-29 18:22:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,391 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 70,268 KB
実行使用メモリ 4,900 KB
最終ジャッジ日時 2023-09-23 03:05:13
合計ジャッジ時間 2,414 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,552 KB
testcase_01 AC 10 ms
4,680 KB
testcase_02 AC 11 ms
4,684 KB
testcase_03 AC 9 ms
4,560 KB
testcase_04 AC 10 ms
4,600 KB
testcase_05 AC 9 ms
4,624 KB
testcase_06 AC 9 ms
4,596 KB
testcase_07 AC 10 ms
4,552 KB
testcase_08 AC 9 ms
4,592 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 29 ms
4,548 KB
testcase_15 AC 30 ms
4,592 KB
testcase_16 AC 27 ms
4,628 KB
testcase_17 AC 22 ms
4,628 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 23 ms
4,544 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 20 ms
4,700 KB
testcase_28 WA -
testcase_29 AC 16 ms
4,576 KB
testcase_30 AC 22 ms
4,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
constexpr ll MOD = 1'000'000'007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> v(n), r(m);
    for(auto &p: v) cin >> p;
    for(auto &p: r) cin >> p;
    int a, b;
    cin >> a >> b;

    const int cntlim = 100010;
    vector<ll> vcnt(cntlim, 0), rcnt(cntlim, 0);
    vcnt[0] = rcnt[0] = 1;
    for(auto &p: v){
        for(int i = cntlim-1; i >= 0; i--){
            if(vcnt[i] > 0) vcnt[i+p] += vcnt[i];
        }
    }
    for(auto &p: r){
        for(int i = cntlim-1; i >= 0; i--){
            if(rcnt[i] > 0) rcnt[i+p] += rcnt[i];
        }
    }
    vcnt[0] = 0;
    rcnt[0] = 0;
    for(int i = 1; i < cntlim; i++) rcnt[i] += rcnt[i-1];
    ll ans = 0;
    for(ll v1 = 1; v1 < cntlim; v1++){
        ll r1 = 0;
        int wa = v1+1;
        while(wa-r1 > 1){
            ll mid = (wa+r1)/2;
            if(mid*a <= v1) r1 = mid;
            else wa = mid;
        }
        ll r2 = v1+1;
        wa = 0;
        while(r2-wa > 1){
            ll mid = (wa+r2)/2;
            if(mid*b >= v1) r2 = mid;
            else wa = mid;
        }
        if(r1 < r2) continue;
        //cerr << r1 << " " << r2 << " ";
        //cerr << vcnt[v1]*(rcnt[r1]-rcnt[r2-1]) << endl;
        ans += vcnt[v1]*(rcnt[r1]-rcnt[r2-1]);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
0