結果

問題 No.1043 直列大学
ユーザー CleyLCleyL
提出日時 2022-05-13 13:07:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,242 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 78,356 KB
実行使用メモリ 7,376 KB
最終ジャッジ日時 2023-09-28 16:12:28
合計ジャッジ時間 3,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,068 KB
testcase_01 AC 9 ms
7,200 KB
testcase_02 AC 13 ms
7,124 KB
testcase_03 AC 9 ms
7,076 KB
testcase_04 AC 9 ms
7,136 KB
testcase_05 AC 9 ms
7,268 KB
testcase_06 AC 9 ms
7,076 KB
testcase_07 AC 11 ms
7,128 KB
testcase_08 AC 11 ms
7,032 KB
testcase_09 AC 55 ms
7,096 KB
testcase_10 AC 64 ms
7,200 KB
testcase_11 AC 93 ms
7,128 KB
testcase_12 AC 101 ms
7,204 KB
testcase_13 AC 85 ms
7,092 KB
testcase_14 AC 89 ms
7,124 KB
testcase_15 AC 98 ms
7,068 KB
testcase_16 AC 88 ms
7,088 KB
testcase_17 AC 66 ms
7,100 KB
testcase_18 AC 66 ms
7,184 KB
testcase_19 AC 83 ms
7,120 KB
testcase_20 AC 65 ms
7,200 KB
testcase_21 AC 77 ms
7,376 KB
testcase_22 AC 81 ms
7,208 KB
testcase_23 AC 100 ms
7,040 KB
testcase_24 AC 72 ms
7,100 KB
testcase_25 AC 84 ms
7,260 KB
testcase_26 AC 89 ms
7,116 KB
testcase_27 AC 48 ms
7,032 KB
testcase_28 AC 84 ms
7,128 KB
testcase_29 WA -
testcase_30 AC 65 ms
7,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int n,m;cin>>n>>m;
  vector<long long> A(n),B(m);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  for(int i = 0; m > i; i++){
    cin>>B[i];
  }
  long long a,b;cin>>a>>b;
  vector<vector<long long>> dp1(2,vector<long long>(101200)),dp2(2,vector<long long>(101200));
  dp1[0][0] = dp2[0][0] = 1;
  for(int i = 0; n > i; i++){
    for(int j = 0; 100000 >= j; j++){
      dp1[1][j+A[i]] = (dp1[1][j+A[i]]+dp1[0][j])%MOD;
      dp1[1][j] = (dp1[1][j]+dp1[0][j])%MOD;
    }
    for(int j = 0; 100000 >= j; j++){
      dp1[0][j] = dp1[1][j];
      dp1[1][j] = 0;
    }
  }
  for(int i = 0; m > i; i++){
    for(int j = 0; 100000 >= j; j++){
      dp2[1][j+B[i]] = (dp2[1][j+B[i]]+dp2[0][j])%MOD;
      dp2[1][j] = (dp2[1][j]+dp2[0][j])%MOD;
    }
    for(int j = 0; 100000 >= j; j++){
      dp2[0][j] = dp2[1][j];
      dp2[1][j] = 0;
    }
  }
  vector<long long> rudp2(101200);
  for(int i = 0; 100000 >= i; i++){
    rudp2[i+1] =  (rudp2[i+1]+rudp2[i]+dp2[0][i])%MOD;
  }
  long long ans = 0;
  for(int i = 1; 100000 >= i; i++){
    ans = (ans+((rudp2[i/a+1] - rudp2[(i+b-1)/b])*dp1[0][i])%MOD)%MOD;
  }
  cout << ans << endl;
  
  
}
0