結果

問題 No.5018 Let's Make a Best-seller Book
ユーザー Kiri8128Kiri8128
提出日時 2023-10-01 15:58:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 400 ms
コード長 4,135 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 93,128 KB
スコア 70,691
平均クエリ数 52.00
最終ジャッジ日時 2023-10-01 15:59:13
合計ジャッジ時間 20,824 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
92,420 KB
testcase_01 AC 129 ms
92,516 KB
testcase_02 AC 129 ms
92,292 KB
testcase_03 AC 128 ms
92,416 KB
testcase_04 AC 129 ms
92,516 KB
testcase_05 AC 128 ms
92,508 KB
testcase_06 AC 129 ms
92,628 KB
testcase_07 AC 129 ms
92,380 KB
testcase_08 AC 132 ms
92,428 KB
testcase_09 AC 126 ms
92,148 KB
testcase_10 AC 125 ms
92,300 KB
testcase_11 AC 124 ms
92,428 KB
testcase_12 AC 127 ms
92,476 KB
testcase_13 AC 127 ms
92,508 KB
testcase_14 AC 127 ms
92,652 KB
testcase_15 AC 128 ms
92,436 KB
testcase_16 AC 127 ms
92,540 KB
testcase_17 AC 125 ms
92,528 KB
testcase_18 AC 133 ms
92,508 KB
testcase_19 AC 130 ms
92,248 KB
testcase_20 AC 129 ms
92,316 KB
testcase_21 AC 127 ms
92,384 KB
testcase_22 AC 127 ms
92,352 KB
testcase_23 AC 128 ms
92,732 KB
testcase_24 AC 128 ms
92,812 KB
testcase_25 AC 130 ms
91,796 KB
testcase_26 AC 129 ms
92,148 KB
testcase_27 AC 128 ms
92,360 KB
testcase_28 AC 126 ms
91,976 KB
testcase_29 AC 127 ms
93,128 KB
testcase_30 AC 127 ms
92,360 KB
testcase_31 AC 126 ms
92,836 KB
testcase_32 AC 127 ms
92,600 KB
testcase_33 AC 133 ms
92,344 KB
testcase_34 AC 126 ms
92,220 KB
testcase_35 AC 126 ms
92,444 KB
testcase_36 AC 125 ms
92,256 KB
testcase_37 AC 127 ms
92,684 KB
testcase_38 AC 126 ms
92,320 KB
testcase_39 AC 127 ms
92,276 KB
testcase_40 AC 126 ms
92,192 KB
testcase_41 AC 130 ms
92,296 KB
testcase_42 AC 127 ms
92,988 KB
testcase_43 AC 127 ms
92,744 KB
testcase_44 AC 127 ms
92,476 KB
testcase_45 AC 128 ms
92,880 KB
testcase_46 AC 127 ms
92,848 KB
testcase_47 AC 128 ms
92,300 KB
testcase_48 AC 131 ms
92,156 KB
testcase_49 AC 126 ms
92,388 KB
testcase_50 AC 126 ms
92,376 KB
testcase_51 AC 127 ms
92,468 KB
testcase_52 AC 128 ms
92,388 KB
testcase_53 AC 128 ms
91,980 KB
testcase_54 AC 129 ms
92,476 KB
testcase_55 AC 128 ms
92,444 KB
testcase_56 AC 155 ms
92,148 KB
testcase_57 AC 126 ms
92,260 KB
testcase_58 AC 127 ms
92,748 KB
testcase_59 AC 129 ms
92,156 KB
testcase_60 AC 128 ms
92,692 KB
testcase_61 AC 128 ms
92,664 KB
testcase_62 AC 129 ms
92,428 KB
testcase_63 AC 128 ms
92,252 KB
testcase_64 AC 128 ms
92,892 KB
testcase_65 AC 128 ms
92,300 KB
testcase_66 AC 129 ms
92,436 KB
testcase_67 AC 128 ms
92,460 KB
testcase_68 AC 126 ms
92,388 KB
testcase_69 AC 125 ms
92,624 KB
testcase_70 AC 129 ms
92,344 KB
testcase_71 AC 156 ms
92,348 KB
testcase_72 AC 127 ms
92,264 KB
testcase_73 AC 125 ms
92,220 KB
testcase_74 AC 127 ms
92,156 KB
testcase_75 AC 129 ms
92,308 KB
testcase_76 AC 128 ms
92,296 KB
testcase_77 AC 129 ms
92,392 KB
testcase_78 AC 128 ms
92,432 KB
testcase_79 AC 131 ms
92,272 KB
testcase_80 AC 126 ms
92,268 KB
testcase_81 AC 127 ms
91,828 KB
testcase_82 AC 126 ms
92,308 KB
testcase_83 AC 126 ms
92,004 KB
testcase_84 AC 127 ms
92,584 KB
testcase_85 AC 126 ms
92,436 KB
testcase_86 AC 155 ms
92,040 KB
testcase_87 AC 127 ms
92,724 KB
testcase_88 AC 127 ms
92,944 KB
testcase_89 AC 130 ms
91,968 KB
testcase_90 AC 155 ms
92,284 KB
testcase_91 AC 126 ms
92,264 KB
testcase_92 AC 128 ms
92,456 KB
testcase_93 AC 127 ms
92,744 KB
testcase_94 AC 127 ms
92,668 KB
testcase_95 AC 126 ms
92,532 KB
testcase_96 AC 128 ms
92,336 KB
testcase_97 AC 127 ms
92,516 KB
testcase_98 AC 127 ms
92,756 KB
testcase_99 AC 126 ms
92,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from random import gauss, random, randrange
try:
    LOCAL
except NameError:
    LOCAL = 0

if LOCAL:
    DEBUG = 1
    LOOP = 100
else:
    DEBUG = 0
    LOOP = 1

def receive():
    global P
    global R
    global money
    global MI, MA
    if DEBUG:
        sell_count = [min(R[i], int(R[i] ** 0.5 * 1.05 ** P[i] * D[i] * (0.75 + random() * 0.5))) for i in range(N)]
        money += 1000 * sum(sell_count)
    else:
        money = int(input())
        sell_count = [int(a) for a in input().split()]
    
    for i in range(N):
        if R[i]:
            ma = (sell_count[i] + 1) / (R[i] ** 0.5 * 0.75 * 1.05 ** P[i])
            mi = sell_count[i] / (R[i] ** 0.5 * 1.25 * 1.05 ** P[i])
            MI[i] = max(mi, MI[i])
            if sell_count[i] < R[i]:
                MA[i] = min(ma, MA[i])
    for i in range(N):
        if R[i]:
            if sell_count[i] * 10 >= 3 * R[i]:
                P[i] = min(P[i] + 1, 60)
            elif sell_count[i] * 10 < R[i]:
                P[i] = max(P[i] - 1, -60)
    
    if DEBUG:
        for i in range(N):
            R[i] -= sell_count[i]
    else:
        for i, a in enumerate(input().split()):
            P[i] = int(a)
        for i, a in enumerate(input().split()):
            R[i] = int(a)
    
    for i in range(N):
        total_sell_count[i] += sell_count[i]
    
def Order():
    global P
    global R
    global money
    target = 10
    buy_count = [0] * N
    for i in range(N):
        if t < 5:
            target = max(1, int(100 / 9 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        elif t < 20:
            target = max(1, int(100 / 9 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        elif t < 40:
            target = max(1, int(100 / 9 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        elif t < 45:
            target = max(1, int(100 / 0.5 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        elif t < 48:
            target = max(1, int(100 / 0.3 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        else:
            target = max(1, int(100 / 0.05 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        buy_count[i] = max(0, target - R[i])
    while 1:
        r = sum(buy_count) * 500 / money
        if r <= 1:
            break
        for i in range(N):
            buy_count[i] = int(buy_count[i] / r)
    
    money -= sum(buy_count) * 500
    if money < 0:
        while 1:
            pass
    assert money >= 0
    for i in range(N):
        R[i] += buy_count[i]
    if not DEBUG:
        print(1, *buy_count)
    
def Advertise(x):
    global money
    money -= 500000 << x - 1
    if money < 0:
        while 1:
            pass
    assert money >= 0
    for i in range(N):
        P[i] = min(P[i] + x, 60)
    if not DEBUG:
        print(2, x)

total_total = 0
for loop in range(LOOP):
    if DEBUG:
        T, N, money = 52, 10, 2 * 10 ** 6
        D = [random() + 0.5 for _ in range(N)]

    else:
        T, N, money = map(int, input().split())
        D = [random() + 0.5 for _ in range(N)]
    total_sell_count = [0] * N
    MA = [1.5] * N
    MI = [0.5] * N
    P = [0] * N
    R = [0] * N
    for t in range(T):
        if (0 < t < 30 and money >= 1300000):
            Advertise(2)
        elif 1 < t < 1 and money >= 600000:
            Advertise(1)
        elif t < 40 and money >= 6000000:
            Advertise(4)
        elif t < 40 and money >= 3000000:
            Advertise(3)
        else:
            Order()
        receive()
        if DEBUG:
            if LOOP == 1:
                print("-" * 20)
                print("t =", t)
                print("Money =", money)
                print("P =", P)
                print("R =", R)
                print("MI =", ["{:.2f}".format(a) for a in MI])
                print("MA =", ["{:.2f}".format(a) for a in MA])
                print("D  =", ["{:.2f}".format(a) for a in D])
                print("Total =", sum(total_sell_count), total_sell_count)
    if LOCAL and LOOP > 1:
        total_total += sum(total_sell_count)
        print("loop =", loop, total_sell_count, sum(total_sell_count), round(total_total / (loop + 1)))
        
0