結果

問題 No.1043 直列大学
ユーザー shop_oneshop_one
提出日時 2020-05-01 22:18:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,244 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 96,136 KB
実行使用メモリ 200,696 KB
最終ジャッジ日時 2023-08-26 14:44:19
合計ジャッジ時間 10,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 278 ms
200,692 KB
testcase_01 AC 249 ms
200,168 KB
testcase_02 AC 395 ms
200,680 KB
testcase_03 AC 244 ms
200,140 KB
testcase_04 AC 244 ms
200,112 KB
testcase_05 AC 234 ms
200,520 KB
testcase_06 AC 234 ms
200,104 KB
testcase_07 AC 327 ms
200,484 KB
testcase_08 AC 307 ms
200,260 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

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 5050000
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+1,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);
  for(int i=0;i<MAX;i++){
    sum[i+1] = (sum[i] + vsum[i][0])%MOD;
  }
  cin >> a >> b;
  for(int i=1;i<MAX;i++){
    ll l = a*i,r=i*b;
    if(r>=MAX) break;
    ans = (ans+(sum[r+1]-sum[l])*rsum[i][0]+MOD)%MOD;
  }
  cout << ans << endl;
}
0