結果
問題 | No.2390 Udon Coupon (Hard) |
ユーザー | cleantted |
提出日時 | 2023-04-26 21:59:42 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,481 bytes |
コンパイル時間 | 463 ms |
コンパイル使用メモリ | 11,276 KB |
実行使用メモリ | 104,896 KB |
最終ジャッジ日時 | 2023-09-26 07:59:04 |
合計ジャッジ時間 | 9,991 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
15,364 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 39 ms
10,968 KB |
testcase_06 | WA | - |
testcase_07 | AC | 38 ms
10,996 KB |
testcase_08 | AC | 37 ms
10,972 KB |
testcase_09 | WA | - |
testcase_10 | AC | 40 ms
11,092 KB |
testcase_11 | AC | 39 ms
11,004 KB |
testcase_12 | AC | 46 ms
11,352 KB |
testcase_13 | AC | 44 ms
11,116 KB |
testcase_14 | AC | 44 ms
11,116 KB |
testcase_15 | AC | 37 ms
10,976 KB |
testcase_16 | WA | - |
testcase_17 | AC | 48 ms
11,260 KB |
testcase_18 | AC | 111 ms
12,856 KB |
testcase_19 | AC | 110 ms
12,896 KB |
testcase_20 | WA | - |
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 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | TLE | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
ソースコード
import sys from collections import deque, Counter from math import gcd, log10, pi, sqrt, ceil from bisect import bisect, bisect_left, bisect_right, insort from typing import Iterable, TypeVar, Union, Tuple, Iterator, List # import bisect import copy import heapq import itertools import math import random from fractions import Fraction from functools import lru_cache, partial, cmp_to_key import operator # import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') # import string # import networkx as nx input = sys.stdin.readline sys.setrecursionlimit(10000000) # mod = 10 ** 9 + 7 mod = 998244353 # mod = 1 << 128 # mod = 10 ** 30 + 1 INF = 1 << 61 DIFF = 10 ** -9 DX = [1, 0, -1, 0, 1, 1, -1, -1] DY = [0, 1, 0, -1, 1, -1, 1, -1] def read_values(): return tuple(map(int, input().split())) def read_index(): return tuple(map(lambda x: int(x) - 1, input().split())) def read_list(): return list(read_values()) def read_lists(N): return [read_list() for _ in range(N)] def main(): N = int(input()) S = read_lists(3) def lcm(a, b): return a * b // math.gcd(a, b) g = lcm(S[0][0], lcm(S[1][0], S[2][0])) gv = max(g // a * b for a, b in S) res = N // g * gv % mod N %= g dp = [0] * (N + 1) for i in range(N): dp[i + 1] = max(dp[i + 1], dp[i]) for a, b in S: if i + a <= N: dp[i + a] = max(dp[i + a], dp[i] + b) print((res + dp[-1]) % mod) if __name__ == "__main__": main()