QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#761155#9552. The ChariotNyansWA 23ms10700kbPython31.4kb2024-11-18 21:12:512024-11-18 21:12:51

Judging History

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

  • [2024-11-18 21:12:51]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:10700kb
  • [2024-11-18 21:12:51]
  • 提交

answer


def solve():
    A, B, C, X, Y, D = map(int, input().split())
    if D <= X:
        print(A)
    elif D <= X + Y:
        cnt = D // X
        rest = D - cnt * X
        if rest != 0:
            cnt += 1
        ans = min(cnt * A, A + B * (D - X))
        ans = min(ans, (cnt - 1) * A + B * rest)
        print(ans)
    else:
        cnt = D // X
        rest = D - cnt * X
        if rest != 0:
            cnt += 1
        k = 1 + (Y - rest) // X
        if k * X + rest < X + Y:
            k += 1
        ans = min(A + B * Y + C * (D - X - Y), cnt * A)
        ans = min(ans, (cnt - k) * A + B * Y + (k * X + rest - X - Y) * C)
        if rest + X <= Y:
            ans = min(ans, (cnt - 1) * A + B * (rest + X))
        cnt = D // (X + Y)
        rest = D - cnt * (X + Y)
        # print(A + B * Y)
        if rest > 0 and rest <= X:
            ans = min(ans, cnt * (A + B * Y) + A - B * min((X - rest), Y * cnt))
        else:
            ans = min(ans, cnt * (A + B * Y) + A + B * (rest - X))
        count = (X + Y) // X
        if count * X != (X + Y):
            count += 1
        delta = count * X + (cnt - 1) * (X + Y) - D
        ans = min(ans, (cnt - 1) * (A + Y * B) + count * A - delta * B)
        ans = min(ans, (cnt - 1) * (A + Y * B) + (D - (cnt - 1) * (X + Y)) * C)
        print(ans)

if __name__ == "__main__":
    T = int(input())
    while T:
        solve()
        T -= 1

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 15ms
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
3226
999
10000000000099799

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 10700kb

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:

126
4
310
-1822
400
57
29
528
300
15
62
312
21
76
48
192
150
130
97
660
76
32
112
180
39
69
36
605
30
23
44
76
285
20
330
325
174
128
32
-884
1
36
30
24
192
170
17
88
83
102
140
-3106
52
81
25
44
8
21
180
49
51
145
55
82
31
85
156
70
158
-595
84
48
156
51
145
174
156
86
2
73
83
5
200
117
-2002
6
-22...

result:

wrong answer 4th lines differ - expected: '114', found: '-1822'