結果

問題 No.1043 直列大学
ユーザー yutasyutas
提出日時 2020-05-01 22:15:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,045 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 93,512 KB
実行使用メモリ 166,692 KB
最終ジャッジ日時 2023-08-26 14:32:15
合計ジャッジ時間 7,391 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,256 KB
testcase_01 AC 4 ms
11,240 KB
testcase_02 AC 5 ms
15,472 KB
testcase_03 AC 4 ms
11,196 KB
testcase_04 AC 4 ms
11,240 KB
testcase_05 AC 3 ms
11,500 KB
testcase_06 AC 3 ms
11,324 KB
testcase_07 AC 4 ms
11,260 KB
testcase_08 AC 4 ms
11,384 KB
testcase_09 WA -
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 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 16 ms
48,172 KB
testcase_30 AC 36 ms
103,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, V[105], R[105], A, B;
ll DPV[105][int(1e5 + 5)], DPR[105][int(1e5 + 5)];
ll SumV[int(1e5 + 5)], SumR[int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) scanf("%d", V + i);
  for (int i = 1; i <= M; i++) scanf("%d", R + i);
  scanf("%d%d", &A, &B);

  DPV[0][0] = 1;
  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= 1e5; j++){
      if (DPV[i - 1][j] == 0) continue;
      DPV[i][j] += DPV[i - 1][j];
      DPV[i][j + V[i]] += DPV[i - 1][j];
    }
  }

  SumV[0] = DPV[N][0];
  for (int i = 1; i <= 1e5; i++){
    SumV[i] = SumV[i - 1] + DPV[N][i];
  }
  
  DPR[0][0] = 1;
  for (int i = 1; i <= M; i++){
    for (int j = 0; j <= 1e5; j++){
      if (DPR[i - 1][j] == 0) continue;
      DPR[i][j] += DPR[i - 1][j];
      DPR[i][j + R[i]] += DPR[i - 1][j];
    }
  }

  SumR[0] = DPR[M][0];
  for (int i = 1; i <= 1e5 + 1; i++){
    SumR[i] = SumR[i - 1] + DPR[M][i];
  }
  
  ll ans = 0;
  for (int i = 1; i <= 1e5 + 1; i++){
    if (SumR[i] == SumR[i - 1]) continue;
    ll now = SumR[i] - SumR[i - 1]; 

    int nowA = A * i - 1, nowB = B * i;
    if (nowB > 1e5) nowB = 1e5 + 1;
    ans += now * (SumV[nowB] - SumV[nowA]);
  }
  printf("%lld\n", ans % MOD);

  return 0;
}
0