結果

問題 No.1043 直列大学
ユーザー 259_Momone259_Momone
提出日時 2020-05-01 21:51:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 997 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 169,684 KB
実行使用メモリ 4,768 KB
最終ジャッジ日時 2023-08-26 09:19:59
合計ジャッジ時間 3,120 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, M, Sv{1}, Sr{1};
    cin >> N >> M;
    vector<unsigned long> dp1{1}, dp2{1};
    dp1.reserve(50000);
    dp2.reserve(50000);
    for(unsigned long i{0}, V; i < N; ++i){
        cin >> V;
        dp1.resize(Sv += V);
        for(unsigned long j{Sv}; j-- > V; )(dp1[j] += dp1[j - V]) %= MOD;
    }
    for(unsigned long i{0}, R; i < M; ++i){
        cin >> R;
        dp2.resize(Sr += R);
        for(unsigned long j{Sr}; j-- > R; )(dp2[j] += dp2[j - R]) %= MOD;
    }
    partial_sum(dp1.rbegin(), dp1.rend(), dp1.rbegin());
    const auto& access = [&Sv, &dp1](long i) -> unsigned long {
        if(i < Sv)return dp1[i] %= MOD;
        return 0;
    };
    unsigned long A, B;
    cin >> A >> B;
    unsigned long ans{0};
    for(unsigned long i{1}; i < Sr; ++i)ans += dp2[i] * (access(A * i) + MOD - access(B * i + 1)) % MOD;
    cout << ans << endl;
    return 0;
}
0