結果

問題 No.1043 直列大学
ユーザー shop_oneshop_one
提出日時 2020-05-01 22:34:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 996 ms / 2,000 ms
コード長 1,420 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 96,960 KB
実行使用メモリ 44,412 KB
最終ジャッジ日時 2023-08-24 05:50:22
合計ジャッジ時間 18,789 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
44,140 KB
testcase_01 AC 58 ms
44,260 KB
testcase_02 AC 95 ms
44,128 KB
testcase_03 AC 57 ms
44,236 KB
testcase_04 AC 57 ms
44,208 KB
testcase_05 AC 57 ms
44,176 KB
testcase_06 AC 57 ms
44,232 KB
testcase_07 AC 76 ms
44,100 KB
testcase_08 AC 76 ms
44,136 KB
testcase_09 AC 507 ms
44,180 KB
testcase_10 AC 573 ms
44,248 KB
testcase_11 AC 817 ms
44,180 KB
testcase_12 AC 924 ms
44,192 KB
testcase_13 AC 774 ms
44,368 KB
testcase_14 AC 824 ms
44,228 KB
testcase_15 AC 885 ms
44,112 KB
testcase_16 AC 868 ms
44,144 KB
testcase_17 AC 606 ms
44,204 KB
testcase_18 AC 619 ms
44,128 KB
testcase_19 AC 861 ms
44,232 KB
testcase_20 AC 607 ms
44,176 KB
testcase_21 AC 753 ms
44,256 KB
testcase_22 AC 793 ms
44,412 KB
testcase_23 AC 996 ms
44,112 KB
testcase_24 AC 697 ms
44,176 KB
testcase_25 AC 819 ms
44,208 KB
testcase_26 AC 861 ms
44,108 KB
testcase_27 AC 429 ms
44,112 KB
testcase_28 AC 794 ms
44,112 KB
testcase_29 AC 277 ms
44,100 KB
testcase_30 AC 586 ms
44,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define MOD 1000000007
#define MAX 1050000
ll vsum[MAX][2]={},rsum[MAX][2]={};
void solve_dp(ll dp[MAX][2],vector<ll> &v,ll n){
  dp[0][0] = 1;
  for(int i=0;i<n;i++){
    for(int j=0;j<MAX;j++){
      dp[j][1] = dp[j][0];
      if(j>=v[i]){
        dp[j][1] += dp[j-v[i]][0];
        dp[j][1] %= MOD;
      }
    }
    for(int j=0;j<MAX;j++){
      dp[j][0] = dp[j][1];
    }
  }
}
signed main(){
  init_io();
  ll n,m,a,b,ans=0;
  cin >> n >> m;
  vector<ll> v(n),r(m);
  vector<ll> sum(MAX,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<m;i++){
    cin >> r[i];
  }
  solve_dp(vsum,v,n);
  solve_dp(rsum,r,m);
  sum[0] = vsum[0][0];
  for(int i=1;i<MAX;i++){
    sum[i] = (sum[i-1] + vsum[i][0])%MOD;
  }
  cin >> a >> b;
  for(int i=1;i<MAX;i++){
    ll l = a*i,r=i*b;
    if(r<MAX){
      ans = (ans+((sum[r]-sum[l-1])*rsum[i][0])%MOD)%MOD;
    }else if(l<MAX){
      ans = (ans+((sum[MAX-1]-sum[l-1])*rsum[i][0])%MOD)%MOD;
    }else{
      break;
    }
    while(ans<0) ans += MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
0