結果

問題 No.1043 直列大学
ユーザー tanimani364tanimani364
提出日時 2020-05-02 20:00:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 2,174 bytes
コンパイル時間 2,506 ms
コンパイル使用メモリ 203,148 KB
実行使用メモリ 168,100 KB
最終ジャッジ日時 2023-08-24 12:44:31
合計ジャッジ時間 6,119 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
167,828 KB
testcase_01 AC 44 ms
167,768 KB
testcase_02 AC 46 ms
167,768 KB
testcase_03 AC 43 ms
167,984 KB
testcase_04 AC 43 ms
167,768 KB
testcase_05 AC 44 ms
167,792 KB
testcase_06 AC 48 ms
167,772 KB
testcase_07 AC 46 ms
167,776 KB
testcase_08 AC 45 ms
167,788 KB
testcase_09 AC 78 ms
167,768 KB
testcase_10 AC 86 ms
167,772 KB
testcase_11 AC 107 ms
167,764 KB
testcase_12 AC 112 ms
167,892 KB
testcase_13 AC 101 ms
167,864 KB
testcase_14 AC 104 ms
167,888 KB
testcase_15 AC 110 ms
168,100 KB
testcase_16 AC 103 ms
167,876 KB
testcase_17 AC 87 ms
167,860 KB
testcase_18 AC 86 ms
167,860 KB
testcase_19 AC 100 ms
167,892 KB
testcase_20 AC 85 ms
167,876 KB
testcase_21 AC 94 ms
167,876 KB
testcase_22 AC 97 ms
167,884 KB
testcase_23 AC 111 ms
167,892 KB
testcase_24 AC 90 ms
167,992 KB
testcase_25 AC 100 ms
167,896 KB
testcase_26 AC 103 ms
168,092 KB
testcase_27 AC 72 ms
167,864 KB
testcase_28 AC 99 ms
167,884 KB
testcase_29 AC 60 ms
167,884 KB
testcase_30 AC 85 ms
167,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

ll dp[105][100005], dp2[105][100005];
void solve()
{
  int n,m;
  cin >> n >> m;
  vector<ll> v(n), r(m);
  rep(i, n) cin >> v[i];
  rep(i, m) cin >> r[i];
  ll a, b;
  cin >> a >> b;
  memset(dp,0, sizeof(dp));
  memset(dp2, 0, sizeof(dp2));
  dp[0][0] = 1;
  dp2[0][0] = 1;
  rep(i, n)
  {
    rep(j,100001){
      if(j+v[i]<=100000){
        dp[i + 1][j + v[i]] += dp[i][j];
        dp[i + 1][j + v[i]] %= mod;
      }
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j] %= mod;
    }
  }
  rep(i,m){
    rep(j,100001){
      if(j+r[i]<=100000){
        dp2[i + 1][j + r[i]] += dp2[i][j];
        dp2[i + 1][j + r[i]] %= mod;
      }
      dp2[i + 1][j] += dp2[i][j];
      dp2[i + 1][j] %= mod;
    }
  }
  ll ans = 0;
  vector<ll> sum(100005);
  rep(i,100000){
    sum[i + 1] = sum[i] + dp[n][i+1];
    sum[i + 1] %= mod;
  }
  for (ll i = 1; i <= 100000; ++i)
  {
    ans+=(((sum[min(100000LL,i*b)]-sum[min(100000LL,i*a-1)]+mod)%mod)*dp2[m][i])%mod;
    ans %= mod;
  }
  cout << ans << endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}

0