結果

問題 No.1043 直列大学
ユーザー CleyLCleyL
提出日時 2022-05-13 13:06:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,242 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 77,276 KB
実行使用メモリ 7,432 KB
最終ジャッジ日時 2023-09-28 16:11:16
合計ジャッジ時間 4,960 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,780 KB
testcase_01 AC 9 ms
6,892 KB
testcase_02 AC 14 ms
6,828 KB
testcase_03 AC 10 ms
6,852 KB
testcase_04 AC 9 ms
6,844 KB
testcase_05 AC 10 ms
6,840 KB
testcase_06 AC 10 ms
6,824 KB
testcase_07 AC 11 ms
7,124 KB
testcase_08 AC 11 ms
6,960 KB
testcase_09 AC 55 ms
6,980 KB
testcase_10 AC 64 ms
6,856 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 48 ms
7,176 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

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>(100200)),dp2(2,vector<long long>(100200));
  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(100200);
  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