結果

問題 No.1043 直列大学
ユーザー McGregorshMcGregorsh
提出日時 2023-07-12 12:36:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 602 ms / 2,000 ms
コード長 2,261 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 253,824 KB
最終ジャッジ日時 2024-09-14 02:32:33
合計ジャッジ時間 14,193 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
101,632 KB
testcase_01 AC 166 ms
97,536 KB
testcase_02 AC 187 ms
104,704 KB
testcase_03 AC 174 ms
97,408 KB
testcase_04 AC 168 ms
97,792 KB
testcase_05 AC 165 ms
98,304 KB
testcase_06 AC 166 ms
98,384 KB
testcase_07 AC 174 ms
100,608 KB
testcase_08 AC 173 ms
102,272 KB
testcase_09 AC 381 ms
175,360 KB
testcase_10 AC 430 ms
191,344 KB
testcase_11 AC 559 ms
240,896 KB
testcase_12 AC 597 ms
253,696 KB
testcase_13 AC 522 ms
227,328 KB
testcase_14 AC 545 ms
234,880 KB
testcase_15 AC 590 ms
248,576 KB
testcase_16 AC 535 ms
231,768 KB
testcase_17 AC 436 ms
195,528 KB
testcase_18 AC 444 ms
196,736 KB
testcase_19 AC 525 ms
225,536 KB
testcase_20 AC 433 ms
194,304 KB
testcase_21 AC 496 ms
215,680 KB
testcase_22 AC 510 ms
220,288 KB
testcase_23 AC 602 ms
253,824 KB
testcase_24 AC 465 ms
205,184 KB
testcase_25 AC 520 ms
225,388 KB
testcase_26 AC 547 ms
234,880 KB
testcase_27 AC 351 ms
163,200 KB
testcase_28 AC 519 ms
224,896 KB
testcase_29 AC 281 ms
136,832 KB
testcase_30 AC 449 ms
192,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
from fractions import Fraction
import math
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement, permutations
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from decimal import Decimal, getcontext, ROUND_HALF_UP
def i_input(): return int(stdin.readline())
def i_map(): return map(int, stdin.readline().split())
def i_list(): return list(i_map())
def s_input(): return stdin.readline()[:-1]
def s_map(): return s_input().split()
def s_list(): return list(s_map())
def lcm(a, b): return a * b // gcd(a, b)
def get_distance(x1, y1, x2, y2):
	  d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	  return d
def rotate(table):
   	  n_fild = []
   	  for x in zip(*table[::-1]):
   	  	  n_fild.append(x)
   	  return n_fild
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7
MOD2 = 998244353
alpa = 'abcdefghijklmnopqrstuvwxyz'
ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'


def main():
   
   N, M = i_map()
   V = i_list()
   R = i_list()
   A, B = i_map()
   
   dp1 = [[0] * 100001 for i in range(N+1)]
   dp1[0][0] = 1
   for i in range(N):
   	  for j in range(100001):
   	  	  if j + V[i] <= 100000:
   	  	  	  dp1[i+1][j+V[i]] += dp1[i][j]
   	  	  	  dp1[i+1][j+V[i]] %= MOD
   	  	  dp1[i+1][j] += dp1[i][j]
   	  	  dp1[i+1][j] %= MOD
   
   dp2 = [[0] * 100001 for i in range(M+1)]
   dp2[0][0] = 1
   for i in range(M):
   	  for j in range(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
   
   score = dp1[-1]
   AS = [score[0]]
   for i in range(1, 100001):
   	  nxt = AS[-1] + score[i]
   	  nxt %= MOD
   	  AS.append(nxt)
   
   ans = 0
   for i in range(100001):
   	  L = min(100000, max(0, i * A-1))
   	  R = min(100000, i * B)
   	  cost = AS[R] - AS[L] 
   	  cost %= MOD
   	  cost *= dp2[-1][i]
   	  cost %= MOD
   	  ans += cost
   	  ans %= MOD
   print(ans)
   
   
if __name__ == '__main__':
    main()



0