QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#806295#9552. The ChariotKKT89WA 22ms10688kbPython31.3kb2024-12-09 03:31:122024-12-09 03:31:12

Judging History

你现在查看的是最新测评结果

  • [2024-12-09 03:31:12]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:10688kb
  • [2024-12-09 03:31:12]
  • 提交

answer

def calc(D, A, B, C, X, Y):
    if D <= X:
        return A
    elif D <= X + Y:
        return A + B * (D - X)
    else:
        return A + B * Y + C * (D - X - Y)


for q in range(int(input())):
    A, B, C, X, Y, D = map(int, input().split())
    # 1台だけ使う場合
    base = calc(D, A, B, C, X, Y)
    res = base
    # ABを出来るだけ使う場合
    res = min(res, D // (X + Y) * (A + B * Y) + calc(D % (X + Y), A, B, C, X, Y))
    # Aを使ってお得になる場合
    c_rem = max(0, D - X - Y)
    b_rem = Y
    res_A = base
    if C * X > A:
        res_A -= (C * X - A) * (c_rem // X)
        c_rem %= X
    if c_rem < X and C * c_rem + B * (X - c_rem) > A:
        res_A -= C * c_rem + B * (X - c_rem) - A
        b_rem -= X - c_rem
        c_rem = 0
    if c_rem == 0:
        if B * X > A:
            res_A -= (B * X - A) * (b_rem // X)
            b_rem %= X
        if b_rem < X and B * b_rem > A:
            res_A -= B * b_rem - A
    res = min(res, res_A)
    # ABを使ってお得になる場合
    c_rem = max(0, D - X - Y)
    b_rem = Y
    res_AB = base
    if C * (X+Y) > A + B * Y:
        res_AB -= (C * (X+Y) - A - B * Y) * (c_rem // (X+Y))
        c_rem %= X+Y
    res = min(res, res_AB)
    # output
    print(res)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 12ms
memory: 10688kb

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
3226
999
10000000000099799

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 22ms
memory: 10596kb

input:

2077
63 88 64 47 55 88
4 75 38 53 33 41
41 1 28 6 13 100
57 88 77 35 5 48
100 36 97 24 93 87
57 25 26 84 62 18
29 11 33 88 86 71
33 16 7 4 73 68
50 65 72 14 43 78
15 31 72 42 39 29
31 10 76 58 35 89
39 55 99 11 16 82
21 18 57 44 80 16
38 31 99 58 59 69
24 22 69 76 14 83
96 40 56 31 14 36
75 84 27 57...

output:

-1043
-2467
311
114
-580
-1436
-888
499
300
-1179
22
312
-1377
-1381
-106
-168
-2622
130
-5413
636
-6472
-182
-668
-770
-6082
-339
36
605
-3110
-1340
-3411
-712
285
-6400
330
325
174
-4576
-1025
36
-1678
-8810
-4794
-1097
-5634
-4351
-234
58
-548
102
-268
86
-694
-737
-1003
-3377
-2408
-2940
-2700
-...

result:

wrong answer 1st lines differ - expected: '126', found: '-1043'