結果

問題 No.1043 直列大学
ユーザー saxofone111saxofone111
提出日時 2020-05-04 11:53:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,314 bytes
コンパイル時間 1,353 ms
コンパイル使用メモリ 164,912 KB
実行使用メモリ 161,652 KB
最終ジャッジ日時 2023-09-06 05:56:55
合計ジャッジ時間 9,830 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
161,328 KB
testcase_01 AC 43 ms
161,304 KB
testcase_02 AC 53 ms
161,388 KB
testcase_03 AC 43 ms
161,440 KB
testcase_04 AC 43 ms
161,316 KB
testcase_05 AC 43 ms
161,520 KB
testcase_06 AC 43 ms
161,452 KB
testcase_07 AC 48 ms
161,304 KB
testcase_08 AC 48 ms
161,508 KB
testcase_09 AC 214 ms
161,436 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 325 ms
161,456 KB
testcase_14 AC 303 ms
161,332 KB
testcase_15 AC 298 ms
161,324 KB
testcase_16 AC 258 ms
161,320 KB
testcase_17 AC 180 ms
161,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 273 ms
161,324 KB
testcase_25 AC 329 ms
161,448 KB
testcase_26 AC 341 ms
161,316 KB
testcase_27 WA -
testcase_28 AC 323 ms
161,304 KB
testcase_29 AC 122 ms
161,328 KB
testcase_30 AC 251 ms
161,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N, M;
ll dpV[101][100100];
ll dpR[101][100100];
ll V[110], R[110];
ll A, B;

ll dpfV(ll n, ll v){
  if(n<0 or v>=100100)return 0;
  if(dpV[n][v]>=0){
    return dpV[n][v];
  }else{
    dpV[n][v]=0;
    if(n==0)dpV[n][v]=1;
    else{
      dpV[n][v]=dpfV(n-1, v)%MOD;
      if(v-V[n-1]>=0){
        dpV[n][v] =mod(dpV[n][v]+dpfV(n-1, v-V[n-1]), MOD);
      }
    }
    return dpV[n][v];
  }
}

ll dpfR(ll n, ll v){
  if(n<0 or v>=100100)return 0;
  if(dpR[n][v]>=0){
    return dpR[n][v];
  }else{
    dpR[n][v]=0;
    if(n==0){
      if(v==0)dpR[n][v]=1;
    }
    else{
      dpR[n][v]=dpfR(n-1, v)%MOD;
      if(v-R[n-1]>=0){
        dpR[n][v] =mod(dpR[n][v]+dpfR(n-1, v-R[n-1]), MOD);
      }
    }
    return dpR[n][v];
  }
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N >> M;
  rep(i, N)cin >> V[i];
  rep(i, M)cin >> R[i];
  cin >> A >> B;
  fill(dpV[0], dpV[101], -100);
  fill(dpR[0], dpR[101], -100);
  ll ans = 0;
  rep(i, 100000){
    ll vnum = dpfV(N, (i+1)*B) - dpfV(N, (i+1)*A - 1);
    //cout << vnum << endl;
    ans = mod(ans+dpfR(M, i+1)*vnum,MOD);
  }
  cout << ans;
  return 0;
}
0