QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#757029 | #9552. The Chariot | ucup-team3734# | RE | 0ms | 0kb | Python3 | 3.0kb | 2024-11-16 23:36:14 | 2024-11-16 23:36:15 |
answer
import sys
from random import randint
def argmin(x):
return min(zip(x, range(len(x))))[1]
if __name__ == '__main__':
sys.stdin = open('input.txt', 'r')
t = int(input())
# t = 1000000
for _ in range(t):
a, b, c, x, y, d = map(int, input().split())
# a, b, c, x, y, d = [randint(1, 100) for _ in range(6)]
def full(z):
if z == 0:
return 0
if z <= x:
return a
if z <= x + y:
return a + (z - x) * b
return a + y * b + (z - x - y) * c
def honest_rec(z):
ans = [0] * (z + 1)
s = [0] * (z + 1)
for i in range(1, z + 1):
step = 1 + argmin([full(k) + ans[i - k] for k in range(1, i + 1)])
ans[i] = full(step) + ans[i - step]
s[i] = step
res = []
while z > 0:
res.append(s[z])
z -= s[z]
return res
def honest(z):
ans = [0] * (z + 1)
for i in range(1, z + 1):
ans[i] = min([full(k) + ans[i - k] for k in range(1, i + 1)])
return ans[z]
def two(z, step):
cur = full(z)
rem = z % step
z -= rem
cur = min(cur, z // step * full(step) + full(rem))
if z >= step:
z -= step
rem += step
cur = min(cur, z // step * full(step) + full(rem))
return cur
def giga(w, depth):
cur = full(w)
if depth == 0:
return cur
for step in [x, x + y]:
z = w
rem = z % step
z -= rem
cur = min(cur, z // step * full(step) + giga(rem, depth - 1))
kek = 3
while z >= step and kek > 0:
kek -= 1
z -= step
rem += step
cur = min(cur, z // step * full(step) + giga(rem, depth - 1))
for step in [x, x + y]:
z = w
rem = 0
kek = 3
while z >= step and kek > 0:
kek -= 1
z -= step
rem += step
cur = min(cur, rem // step * full(step) + giga(z, depth - 1))
return cur
# ans = min([full(d), two(d, x + y), two(d, x)])
ans = giga(d, 2)
print(ans)
# if ans != honest(d):
# print("full", full(d))
# print("two", two(d, x + y))
# print("one", two(d, x))
# print("giga", giga(d, 3))
#
# print(f"got {ans} but correct {honest(d)}")
# print(f"steps: {honest_rec(d)}")
# print(a, b, c, x, y, d)
# exit(0)
# else:
# print("ok")
# print(ans)
# print(honest(d))
詳細信息
Test #1:
score: 0
Dangerous Syscalls
input:
5 160 27 41 3 12 3 160 27 41 3 12 4 160 27 41 3 12 99 1 999 999 1 99 999 999 999 1 1 99 9999999999999999