結果

問題 No.1043 直列大学
ユーザー roarisroaris
提出日時 2020-05-01 21:52:59
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,333 bytes
コンパイル時間 4,537 ms
コンパイル使用メモリ 132,964 KB
実行使用メモリ 165,064 KB
最終ジャッジ日時 2023-08-20 15:01:42
合計ジャッジ時間 7,578 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,972 KB
testcase_01 AC 6 ms
10,528 KB
testcase_02 AC 10 ms
15,516 KB
testcase_03 AC 5 ms
7,940 KB
testcase_04 AC 6 ms
10,788 KB
testcase_05 AC 5 ms
7,980 KB
testcase_06 AC 6 ms
10,664 KB
testcase_07 AC 8 ms
14,848 KB
testcase_08 AC 7 ms
12,164 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 89 ms
137,116 KB
testcase_14 AC 95 ms
145,032 KB
testcase_15 AC 103 ms
159,888 KB
testcase_16 AC 92 ms
142,692 KB
testcase_17 AC 67 ms
107,044 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 79 ms
124,396 KB
testcase_22 AC 83 ms
128,680 KB
testcase_23 WA -
testcase_24 AC 74 ms
114,540 KB
testcase_25 AC 87 ms
136,072 KB
testcase_26 AC 94 ms
145,764 KB
testcase_27 AC 48 ms
74,836 KB
testcase_28 AC 87 ms
134,720 KB
testcase_29 AC 30 ms
46,884 KB
testcase_30 AC 68 ms
102,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
const int MOD = 1000000007;

int N, M;
int V[110];
int R[110];
int A, B;
int dp1[110][100001];
int dp2[110][100001];

signed main() {
    cin >> N >> M;
    rep(i, N) cin >> V[i];
    rep(i, M) cin >> R[i];
    cin >> A >> B;
    
    rep(i, N+1) rep(j, 100001) dp1[i][j] = 0;
    dp1[0][0] = 1;
    rep(i, N) {
        rep(j, 100001) {
            dp1[i+1][j] += dp1[i][j];
            dp1[i+1][j] %= MOD;
            if (j+V[i]<100001) {
                dp1[i+1][j+V[i]] += dp1[i][j];
                dp1[i+1][j+V[i]] %= MOD;
            }
        }
    }
    
    int acc[100002];
    acc[0] = 0;
    rep(i, 100001) acc[i+1] = acc[i]+dp1[N][i];
    
    rep(i, M+1) rep(j, 100001) dp2[i][j] = 0;
    dp2[0][0] = 1;
    rep(i, M) {
        rep(j, 100001) {
            dp2[i+1][j] += dp2[i][j];
            dp2[i+1][j] %= MOD;
            if (j+R[i]<100001) {
                dp2[i+1][j+R[i]] += dp2[i][j];
                dp2[i+1][j+R[i]] %= MOD;
            }
        }
    }
    
    int ans = 0;
    for (int i=1; i<100001; i++) {
        if (i*A<=100000 && i*B<=100000) {
            ans += dp2[M][i]*(acc[i*B+1]-acc[i*A]);
            ans %= MOD;
        }
    }
    
    cout << ans << endl;
}
0