結果

問題 No.27 板の準備
ユーザー vwxyzvwxyz
提出日時 2021-07-17 18:48:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 288 ms / 5,000 ms
コード長 1,162 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 95,152 KB
最終ジャッジ日時 2023-09-21 12:04:13
合計ジャッジ時間 6,627 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 288 ms
94,944 KB
testcase_01 AC 288 ms
94,812 KB
testcase_02 AC 286 ms
94,688 KB
testcase_03 AC 284 ms
94,692 KB
testcase_04 AC 286 ms
94,856 KB
testcase_05 AC 288 ms
94,588 KB
testcase_06 AC 282 ms
95,152 KB
testcase_07 AC 283 ms
94,992 KB
testcase_08 AC 285 ms
94,788 KB
testcase_09 AC 281 ms
94,952 KB
testcase_10 AC 281 ms
95,008 KB
testcase_11 AC 283 ms
94,764 KB
testcase_12 AC 278 ms
94,940 KB
testcase_13 AC 280 ms
94,696 KB
testcase_14 AC 282 ms
94,764 KB
testcase_15 AC 281 ms
94,804 KB
testcase_16 AC 284 ms
95,136 KB
testcase_17 AC 280 ms
95,104 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