結果
問題 | No.5018 Let's Make a Best-seller Book |
ユーザー |
![]() |
提出日時 | 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 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
from random import gauss, random, randrangetry:LOCALexcept NameError:LOCAL = 0if LOCAL:DEBUG = 1LOOP = 1000else:DEBUG = 0LOOP = 1def receive():global Pglobal Rglobal moneyglobal MI, MAif 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 Pglobal Rglobal moneytarget = 10buy_count = [0] * Nfor i in range(N):if t < 5:target = max(1, int(100 / 9 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10elif t < 20:target = max(1, int(100 / 8 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10elif t < 40:target = max(1, int(100 / 4 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10elif t < 45:target = max(1, int(100 / 1 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10elif t < 48:target = max(1, int(100 / 0.3 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10else:target = max(1, int(100 / 0.05 * 1.05 ** P[i] * (MA[i] + MI[i]) / 2 / 10)) * 10buy_count[i] = max(0, target - R[i])while 1:r = sum(buy_count) * 500 / moneyif r <= 1:breakfor i in range(N):buy_count[i] = int(buy_count[i] / r)money -= sum(buy_count) * 500if money < 0:while 1:passassert money >= 0for i in range(N):R[i] += buy_count[i]if not DEBUG:print(1, *buy_count)def Advertise(x):global moneymoney -= 500000 << x - 1if money < 0:while 1:passassert money >= 0for i in range(N):P[i] = min(P[i] + x, 60)if not DEBUG:print(2, x)total_total = 0for loop in range(LOOP):if DEBUG:T, N, money = 52, 10, 2 * 10 ** 6D = [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] * NMA = [1.5] * NMI = [0.5] * NP = [0] * NR = [0] * Nfor 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))