結果

問題 No.1043 直列大学
ユーザー roarisroaris
提出日時 2020-05-01 21:48:24
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,329 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 133,980 KB
実行使用メモリ 165,028 KB
最終ジャッジ日時 2023-08-20 15:01:22
合計ジャッジ時間 5,063 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
11,548 KB
testcase_01 AC 5 ms
10,900 KB
testcase_02 AC 8 ms
15,260 KB
testcase_03 AC 4 ms
7,884 KB
testcase_04 AC 5 ms
7,952 KB
testcase_05 AC 5 ms
8,468 KB
testcase_06 AC 5 ms
8,368 KB
testcase_07 AC 7 ms
12,032 KB
testcase_08 AC 7 ms
11,760 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 106 ms
135,628 KB
testcase_14 AC 104 ms
145,028 KB
testcase_15 AC 104 ms
158,732 KB
testcase_16 AC 91 ms
142,592 KB
testcase_17 AC 67 ms
105,064 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 80 ms
122,876 KB
testcase_22 AC 83 ms
128,744 KB
testcase_23 WA -
testcase_24 AC 74 ms
114,228 KB
testcase_25 AC 86 ms
136,116 KB
testcase_26 AC 94 ms
145,072 KB
testcase_27 AC 44 ms
73,604 KB
testcase_28 AC 88 ms
134,728 KB
testcase_29 AC 30 ms
46,856 KB
testcase_30 AC 65 ms
102,376 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) 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) 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