結果

問題 No.27 板の準備
ユーザー vwxyzvwxyz
提出日時 2021-07-17 18:43:37
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 309 ms / 5,000 ms
コード長 1,136 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 95,352 KB
最終ジャッジ日時 2023-09-21 11:59:10
合計ジャッジ時間 7,284 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 302 ms
95,116 KB
testcase_01 AC 296 ms
94,904 KB
testcase_02 AC 297 ms
94,944 KB
testcase_03 AC 296 ms
95,136 KB
testcase_04 AC 298 ms
95,068 KB
testcase_05 AC 301 ms
95,048 KB
testcase_06 AC 302 ms
95,060 KB
testcase_07 AC 304 ms
94,856 KB
testcase_08 AC 304 ms
95,204 KB
testcase_09 AC 300 ms
94,976 KB
testcase_10 AC 309 ms
95,016 KB
testcase_11 AC 302 ms
94,944 KB
testcase_12 AC 302 ms
95,104 KB
testcase_13 AC 302 ms
95,172 KB
testcase_14 AC 304 ms
95,180 KB
testcase_15 AC 306 ms
95,352 KB
testcase_16 AC 305 ms
94,880 KB
testcase_17 AC 303 ms
95,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
from collections import Counter, deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

V0,V1,V2,V3=map(int,readline().split())
inf=1<<60
ans=inf
for C in range(1,31):
    for B in range(1,C):
        for A in range(1,B):
            cnt=[inf]*31
            for a in range(31):
                for b in range(31):
                    for c in range(31):
                        if A*a+B*b+C*c>30:
                            break
                        cnt[A*a+B*b+C*c]=min(cnt[A*a+B*b+C*c],a+b+c)
            ans=min(ans,cnt[V0]+cnt[V1]+cnt[V2]+cnt[V3])
print(ans)
0