結果

問題 No.2390 Udon Coupon (Hard)
ユーザー cleanttedcleantted
提出日時 2023-07-15 18:41:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 533 ms / 2,000 ms
コード長 1,570 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 92,928 KB
最終ジャッジ日時 2024-04-15 20:56:32
合計ジャッジ時間 13,258 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
92,288 KB
testcase_01 AC 155 ms
91,904 KB
testcase_02 AC 161 ms
92,416 KB
testcase_03 AC 160 ms
92,544 KB
testcase_04 AC 159 ms
92,544 KB
testcase_05 AC 171 ms
92,928 KB
testcase_06 AC 153 ms
91,904 KB
testcase_07 AC 154 ms
91,904 KB
testcase_08 AC 156 ms
91,904 KB
testcase_09 AC 533 ms
92,416 KB
testcase_10 AC 165 ms
92,672 KB
testcase_11 AC 163 ms
92,032 KB
testcase_12 AC 164 ms
92,416 KB
testcase_13 AC 162 ms
92,544 KB
testcase_14 AC 162 ms
92,544 KB
testcase_15 AC 158 ms
92,032 KB
testcase_16 AC 158 ms
92,416 KB
testcase_17 AC 160 ms
92,288 KB
testcase_18 AC 169 ms
92,416 KB
testcase_19 AC 163 ms
92,544 KB
testcase_20 AC 158 ms
91,776 KB
testcase_21 AC 160 ms
91,776 KB
testcase_22 AC 163 ms
92,288 KB
testcase_23 AC 159 ms
92,288 KB
testcase_24 AC 205 ms
92,672 KB
testcase_25 AC 219 ms
92,416 KB
testcase_26 AC 213 ms
92,544 KB
testcase_27 AC 211 ms
92,416 KB
testcase_28 AC 211 ms
92,672 KB
testcase_29 AC 275 ms
92,544 KB
testcase_30 AC 249 ms
92,544 KB
testcase_31 AC 279 ms
92,544 KB
testcase_32 AC 273 ms
92,544 KB
testcase_33 AC 262 ms
92,672 KB
testcase_34 AC 362 ms
92,544 KB
testcase_35 AC 357 ms
92,416 KB
testcase_36 AC 351 ms
92,544 KB
testcase_37 AC 368 ms
92,544 KB
testcase_38 AC 356 ms
92,288 KB
testcase_39 AC 340 ms
92,544 KB
testcase_40 AC 263 ms
92,416 KB
testcase_41 AC 322 ms
92,800 KB
testcase_42 AC 215 ms
92,416 KB
testcase_43 AC 334 ms
92,928 KB
testcase_44 AC 325 ms
92,672 KB
testcase_45 AC 268 ms
92,544 KB
testcase_46 AC 210 ms
92,416 KB
testcase_47 AC 202 ms
92,544 KB
testcase_48 AC 352 ms
92,544 KB
testcase_49 AC 151 ms
91,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
    S += S
    A = max(a for a, _ in S)

    res = 0
    for k in range(3):
        A1, B1 = S[k]
        A2, B2 = S[k + 1]
        A3, B3 = S[k + 2]

        for i in range(A + 10):
            N1 = N - A1 * i
            if N1 < 0:
                break
            r1 = i * B1

            for j in range(A + 10):
                N2 = N1 - A2 * j
                if N2 < 0:
                    break
                
                res = max(res, r1 + j * B2 + (N2 // A3) * B3)
    print(res)


if __name__ == "__main__":
    main()
0