QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#757336 | #9552. The Chariot | ucup-team3099# | WA | 9ms | 10648kb | Python3 | 1.4kb | 2024-11-17 05:06:06 | 2024-11-17 05:06:07 |
Judging History
answer
t = int(input())
for test in range(t):
a, b, c, x, y, d = list(map(int,input().split()))
def firstCase():
# case using only a and b
# using N trips, valid iff (x + y) * N >= d
# N >= d / (x + y)
# cost N * a + b * max(d - N * x, 0)
# to reach 0: d - N * x <= 0, d <= N * x, D >= d / x
low = (d + x + y - 1) // (x + y)
high = (d + x - 1) // x
mid = max(low - 1, low)
return min(high * a, low * a + b * max(0, d - low * x), mid * a + b * max(0, d - mid * x))
def secondCase():
# case using a, b and c
# priority to using C
# one trip uses up until b and uses rest c
# the rest uses only a
# using N trips:
# cost N * a + b * x + max(d - N * x - y, 0) * c
# to reach 0: d - N * x - y <= 0, d - y <= N * x, N >= (d - y) / x
high = max(1, (d - y + x - 1) // x)
low = max(high - 1, 1)
return min(low * a + b * y + max(d - low * x - y, 0) * c, high * a + b * y + max(d - high * x - y, 0) * c, a + b + max(d - x - y, 0) * c)
def thirdCase():
# every trip uses a, b completely
# using N trips:
# cost N * (a + b * y) + max(d - N * (x + y), 0)
# to reach 0: d - N * (x + y) <= 0, N >= d / (x + y)
high = (d + x + y - 1) // (x + y)
low = max(high - 1, 1)
return min(low * (a + b * y) + max(d - low * (x + y), 0) * c, high * (a + b * y) + max(d - high * (x + y), 0) * c)
print(firstCase(), secondCase(), thirdCase())
print(min(firstCase(), secondCase(), thirdCase()))
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 9ms
memory: 10648kb
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
output:
160 187 484 160 187 187 484 187 3226 3631 3273 3226 999 99801 989019 999 9989999999999999001 10000000000001897 9989999999999900199 10000000000001897
result:
wrong answer 1st lines differ - expected: '160', found: '160 187 484'