結果

問題 No.1043 直列大学
ユーザー tanimani364tanimani364
提出日時 2020-05-02 17:15:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,157 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 204,072 KB
実行使用メモリ 168,268 KB
最終ジャッジ日時 2023-08-28 23:35:18
合計ジャッジ時間 11,738 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
167,908 KB
testcase_01 AC 49 ms
167,820 KB
testcase_02 AC 51 ms
167,908 KB
testcase_03 AC 48 ms
167,920 KB
testcase_04 AC 46 ms
168,140 KB
testcase_05 AC 47 ms
167,876 KB
testcase_06 AC 46 ms
167,868 KB
testcase_07 AC 47 ms
168,000 KB
testcase_08 AC 46 ms
167,928 KB
testcase_09 AC 77 ms
167,992 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 94 ms
167,936 KB
testcase_22 AC 96 ms
167,876 KB
testcase_23 WA -
testcase_24 AC 90 ms
167,960 KB
testcase_25 AC 99 ms
167,984 KB
testcase_26 AC 102 ms
167,988 KB
testcase_27 AC 71 ms
167,912 KB
testcase_28 AC 98 ms
167,876 KB
testcase_29 AC 60 ms
168,004 KB
testcase_30 AC 85 ms
168,116 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<int> v(n), r(m);
  rep(i, n) cin >> v[i];
  rep(i, m) cin >> r[i];
  int 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,1e5){
    sum[i + 1] = sum[i] + dp[n][i+1];
  }
  for (int i = 1; i <= 100000; ++i)
  {
    if(i*b>100000)
      continue;
    ans+=(((sum[i*b]-sum[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