結果

問題 No.27 板の準備
ユーザー vwxyzvwxyz
提出日時 2021-07-17 18:50:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,067 ms / 5,000 ms
コード長 1,136 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 10,536 KB
最終ジャッジ日時 2023-09-21 12:07:03
合計ジャッジ時間 39,519 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,030 ms
10,376 KB
testcase_01 AC 2,039 ms
10,304 KB
testcase_02 AC 1,970 ms
10,360 KB
testcase_03 AC 1,986 ms
10,396 KB
testcase_04 AC 1,991 ms
10,380 KB
testcase_05 AC 2,045 ms
10,376 KB
testcase_06 AC 2,027 ms
10,440 KB
testcase_07 AC 1,986 ms
10,440 KB
testcase_08 AC 2,066 ms
10,444 KB
testcase_09 AC 2,027 ms
10,536 KB
testcase_10 AC 2,042 ms
10,460 KB
testcase_11 AC 2,001 ms
10,488 KB
testcase_12 AC 2,000 ms
10,532 KB
testcase_13 AC 2,067 ms
10,364 KB
testcase_14 AC 2,012 ms
10,300 KB
testcase_15 AC 2,019 ms
10,404 KB
testcase_16 AC 1,978 ms
10,336 KB
testcase_17 AC 2,001 ms
10,408 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