結果

問題 No.5018 Let's Make a Best-seller Book
ユーザー Kiri8128Kiri8128
提出日時 2023-10-01 16:05:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 400 ms
コード長 4,222 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 93,000 KB
スコア 92,203
平均クエリ数 52.00
最終ジャッジ日時 2023-10-01 16:06:15
合計ジャッジ時間 19,487 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
92,612 KB
testcase_01 AC 128 ms
92,624 KB
testcase_02 AC 130 ms
92,120 KB
testcase_03 AC 128 ms
92,620 KB
testcase_04 AC 127 ms
92,432 KB
testcase_05 AC 128 ms
92,736 KB
testcase_06 AC 135 ms
88,792 KB
testcase_07 AC 128 ms
92,588 KB
testcase_08 AC 125 ms
88,572 KB
testcase_09 AC 127 ms
92,164 KB
testcase_10 AC 127 ms
91,920 KB
testcase_11 AC 128 ms
92,528 KB
testcase_12 AC 128 ms
92,824 KB
testcase_13 AC 132 ms
88,260 KB
testcase_14 AC 130 ms
92,432 KB
testcase_15 AC 128 ms
89,112 KB
testcase_16 AC 130 ms
92,832 KB
testcase_17 AC 128 ms
89,128 KB
testcase_18 AC 130 ms
92,352 KB
testcase_19 AC 129 ms
92,476 KB
testcase_20 AC 136 ms
92,492 KB
testcase_21 AC 129 ms
92,496 KB
testcase_22 AC 129 ms
93,000 KB
testcase_23 AC 128 ms
92,752 KB
testcase_24 AC 128 ms
88,824 KB
testcase_25 AC 131 ms
92,428 KB
testcase_26 AC 131 ms
92,480 KB
testcase_27 AC 138 ms
92,336 KB
testcase_28 AC 129 ms
92,116 KB
testcase_29 AC 155 ms
92,356 KB
testcase_30 AC 129 ms
92,880 KB
testcase_31 AC 129 ms
92,380 KB
testcase_32 AC 132 ms
92,956 KB
testcase_33 AC 127 ms
88,528 KB
testcase_34 AC 136 ms
92,488 KB
testcase_35 AC 130 ms
92,676 KB
testcase_36 AC 128 ms
88,972 KB
testcase_37 AC 127 ms
88,840 KB
testcase_38 AC 130 ms
92,704 KB
testcase_39 AC 127 ms
89,304 KB
testcase_40 AC 132 ms
92,312 KB
testcase_41 AC 138 ms
89,336 KB
testcase_42 AC 128 ms
88,480 KB
testcase_43 AC 131 ms
92,140 KB
testcase_44 AC 129 ms
92,720 KB
testcase_45 AC 130 ms
92,384 KB
testcase_46 AC 130 ms
92,376 KB
testcase_47 AC 128 ms
91,976 KB
testcase_48 AC 131 ms
92,236 KB
testcase_49 AC 133 ms
92,464 KB
testcase_50 AC 126 ms
88,500 KB
testcase_51 AC 128 ms
92,536 KB
testcase_52 AC 128 ms
92,224 KB
testcase_53 AC 128 ms
89,096 KB
testcase_54 AC 137 ms
92,324 KB
testcase_55 AC 129 ms
88,768 KB
testcase_56 AC 155 ms
88,948 KB
testcase_57 AC 129 ms
92,336 KB
testcase_58 AC 128 ms
92,504 KB
testcase_59 AC 129 ms
92,748 KB
testcase_60 AC 126 ms
88,720 KB
testcase_61 AC 127 ms
88,928 KB
testcase_62 AC 130 ms
92,744 KB
testcase_63 AC 156 ms
89,200 KB
testcase_64 AC 129 ms
92,320 KB
testcase_65 AC 131 ms
92,012 KB
testcase_66 AC 129 ms
92,132 KB
testcase_67 AC 128 ms
88,864 KB
testcase_68 AC 133 ms
92,364 KB
testcase_69 AC 127 ms
89,152 KB
testcase_70 AC 143 ms
92,488 KB
testcase_71 AC 137 ms
92,420 KB
testcase_72 AC 135 ms
92,656 KB
testcase_73 AC 133 ms
92,408 KB
testcase_74 AC 133 ms
92,780 KB
testcase_75 AC 130 ms
92,180 KB
testcase_76 AC 133 ms
92,468 KB
testcase_77 AC 140 ms
92,508 KB
testcase_78 AC 128 ms
91,936 KB
testcase_79 AC 129 ms
92,488 KB
testcase_80 AC 131 ms
92,708 KB
testcase_81 AC 130 ms
92,856 KB
testcase_82 AC 129 ms
92,040 KB
testcase_83 AC 127 ms
88,640 KB
testcase_84 AC 139 ms
92,880 KB
testcase_85 AC 127 ms
92,500 KB
testcase_86 AC 130 ms
92,288 KB
testcase_87 AC 129 ms
92,700 KB
testcase_88 AC 128 ms
88,456 KB
testcase_89 AC 130 ms
92,268 KB
testcase_90 AC 125 ms
89,132 KB
testcase_91 AC 126 ms
89,056 KB
testcase_92 AC 127 ms
88,452 KB
testcase_93 AC 174 ms
88,724 KB
testcase_94 AC 129 ms
92,108 KB
testcase_95 AC 128 ms
92,936 KB
testcase_96 AC 126 ms
88,996 KB
testcase_97 AC 127 ms
92,740 KB
testcase_98 AC 127 ms
88,500 KB
testcase_99 AC 129 ms
92,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if LOCAL:
    DEBUG = 1
    LOOP = 1000
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 / 8 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        elif t < 40:
            target = max(1, int(100 / 4 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10
        elif t < 45:
            target = max(1, int(100 / 1 * 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:
        total_total += sum(total_sell_count)
    if LOCAL and 20 >= LOOP > 1:
        print("loop =", loop, total_sell_count, sum(total_sell_count), round(total_total / (loop + 1)))
if LOCAL and LOOP > 1:
    print("LOOP =", LOOP, round(total_total / LOOP))
0