結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
10,380 KB
testcase_01 AC 154 ms
10,536 KB
testcase_02 AC 152 ms
10,476 KB
testcase_03 AC 146 ms
10,332 KB
testcase_04 AC 148 ms
10,536 KB
testcase_05 AC 152 ms
10,424 KB
testcase_06 AC 150 ms
10,372 KB
testcase_07 AC 147 ms
10,472 KB
testcase_08 AC 146 ms
10,388 KB
testcase_09 AC 145 ms
10,376 KB
testcase_10 AC 150 ms
10,536 KB
testcase_11 AC 150 ms
10,340 KB
testcase_12 AC 146 ms
10,376 KB
testcase_13 AC 146 ms
10,376 KB
testcase_14 AC 149 ms
10,392 KB
testcase_15 AC 145 ms
10,408 KB
testcase_16 AC 146 ms
10,368 KB
testcase_17 AC 147 ms
10,476 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
            cnt[0]=0
            for i in range(1,31):
                if i>=A:
                    cnt[i]=min(cnt[i],cnt[i-A]+1)
                if i>=B:
                    cnt[i]=min(cnt[i],cnt[i-B]+1)
                if i>=C:
                    cnt[i]=min(cnt[i],cnt[i-C]+1)
            ans=min(ans,cnt[V0]+cnt[V1]+cnt[V2]+cnt[V3])
print(ans)
0