結果

問題 No.1043 直列大学
ユーザー motmot
提出日時 2020-05-01 22:21:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,068 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 79,028 KB
実行使用メモリ 160,408 KB
最終ジャッジ日時 2023-08-26 14:53:33
合計ジャッジ時間 4,499 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,188 KB
testcase_01 AC 3 ms
5,404 KB
testcase_02 AC 5 ms
10,896 KB
testcase_03 AC 3 ms
5,400 KB
testcase_04 AC 2 ms
5,404 KB
testcase_05 AC 3 ms
5,464 KB
testcase_06 AC 3 ms
5,396 KB
testcase_07 AC 4 ms
10,812 KB
testcase_08 AC 5 ms
10,760 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 119 ms
146,004 KB
testcase_12 RE -
testcase_13 AC 75 ms
133,540 KB
testcase_14 AC 76 ms
141,892 KB
testcase_15 AC 83 ms
156,172 KB
testcase_16 AC 73 ms
139,852 KB
testcase_17 AC 53 ms
102,980 KB
testcase_18 WA -
testcase_19 AC 71 ms
131,600 KB
testcase_20 AC 52 ms
100,928 KB
testcase_21 AC 65 ms
121,420 KB
testcase_22 AC 68 ms
127,504 KB
testcase_23 AC 84 ms
158,276 KB
testcase_24 AC 60 ms
113,224 KB
testcase_25 AC 70 ms
131,796 KB
testcase_26 AC 75 ms
141,892 KB
testcase_27 AC 36 ms
70,152 KB
testcase_28 AC 68 ms
131,588 KB
testcase_29 AC 23 ms
43,660 KB
testcase_30 AC 55 ms
101,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

ll VDP[105][100005];
ll RDP[105][100005];

int main() {
    int N, M;
    cin>>N>>M;
    vector<ll> V(N), R(M);
    for(int i=0;i<N;++i){
        cin>>V[i];
    }
    for(int i=0;i<M;++i){
        cin>>R[i];
    }
    int A, B;
    cin>>A>>B;
    VDP[0][V[0]] = 1;
    RDP[0][R[0]] = 1;
    for(int i=1;i<N;++i){
        for(int j=1;j<=100000;++j){
            if(V[i]<=j){
                if(V[i]==j){
                    VDP[i][j] = VDP[i-1][j] + 1;
                }
                else{
                    VDP[i][j] = VDP[i-1][j] + VDP[i-1][j-V[i]];
                }
            }
            else{
                VDP[i][j] = VDP[i-1][j];
            }
            VDP[i][j] %= mod;
        }
    }
    for(int i=1;i<M;++i){
        for(int j=1;j<=100000;++j){
            if(R[i]<=j){
                if(R[i]==j){
                    RDP[i][j] = RDP[i-1][j] + 1;
                }
                else{
                    RDP[i][j] = RDP[i-1][j] + RDP[i-1][j-R[i]];
                }
            }
            else{
                RDP[i][j] = RDP[i-1][j];
            }
            RDP[i][j] %= mod;
        }
    }
    for(int i=1;i<100003;++i){
        VDP[N-1][i] += VDP[N-1][i-1];
        //RDP[i] += RDP[i-1];
    }
    /**
    for(int i=0;i<N;++i){
        for(int j=0;j<100;++j){
            cout<<VDP[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    **/
    ll ans = 0;
    for(int i=1;i<=100000;++i){
        if(i*A>100000) break;
        if(i*B>100000){
            ans += ((VDP[N-1][100002] - VDP[N-1][i*A-1]) * RDP[M-1][i]) % mod;
            ans %= mod;
        }
        else{
            ans += ((VDP[N-1][i*B] - VDP[N-1][i*A-1]) * RDP[M-1][i]) % mod;
            ans %= mod;
        }
    }
    cout<<ans<<endl;
}
0