結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,036 KB
testcase_01 AC 5 ms
5,092 KB
testcase_02 AC 7 ms
4,980 KB
testcase_03 AC 4 ms
5,000 KB
testcase_04 AC 5 ms
4,972 KB
testcase_05 AC 5 ms
4,924 KB
testcase_06 AC 5 ms
5,092 KB
testcase_07 AC 6 ms
4,924 KB
testcase_08 AC 6 ms
4,928 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 47 ms
5,276 KB
testcase_15 AC 51 ms
4,984 KB
testcase_16 AC 46 ms
4,928 KB
testcase_17 AC 34 ms
4,932 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 25 ms
5,100 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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