QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#827517#9552. The ChariotLilyWhiteWA 18ms11392kbPython31.1kb2024-12-23 00:43:182024-12-23 00:43:18

Judging History

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

  • [2024-12-23 00:43:18]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:11392kb
  • [2024-12-23 00:43:18]
  • 提交

answer

import sys

def minimal_travel_cost(A, B, C, X, Y, D):
    # Option1: Re-hail every X meters
    option1 = ((D + X - 1) // X) * A
    
    # Option2: Re-hail every (X + Y) meters
    k = D // (X + Y)
    R = D % (X + Y)
    if R == 0:
        option2 = k * (A + B * Y)
    else:
        option2 = k * (A + B * Y) + A + B * (R - X)
    
    # Option3: Take a single cab for the entire journey
    if D <= X:
        option3 = A
    elif D <= X + Y:
        option3 = A + B * (D - X)
    else:
        option3 = A + B * Y + C * (D - X - Y)
    
    # Return the minimal cost
    return min(option1, option2, option3)

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    T = int(data[0])
    idx = 1
    results = []
    for _ in range(T):
        A = int(data[idx])
        B = int(data[idx+1])
        C = int(data[idx+2])
        X = int(data[idx+3])
        Y = int(data[idx+4])
        D = int(data[idx+5])
        idx +=6
        cost = minimal_travel_cost(A, B, C, X, Y, D)
        results.append(str(cost))
    print('\n'.join(results))

if __name__ == "__main__":
    main()

詳細信息

Test #1:

score: 100
Accepted
time: 16ms
memory: 10492kb

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: 18ms
memory: 11392kb

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
-896
310
-1822
400
-1593
-158
561
300
-388
62
312
-483
76
48
192
150
130
-5777
672
-4248
-205
112
186
-55
138
36
605
-866
-817
88
-4460
285
-5680
330
325
174
128
32
36
-2009
-4374
-1374
24
192
170
17
88
-1072
102
140
-3106
-578
52
-599
-3673
-1360
-357
180
-3617
-3027
145
-3175
-8
-567
-1724
156...

result:

wrong answer 2nd lines differ - expected: '4', found: '-896'