QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#757029#9552. The Chariotucup-team3734#RE 0ms0kbPython33.0kb2024-11-16 23:36:142024-11-16 23:36:15

Judging History

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

  • [2024-11-16 23:36:15]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-16 23:36:14]
  • 提交

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

output:


result: