import copy import random from time import perf_counter import argparse import sys import math class TimeKeeper: def __init__(self): self.start_time = perf_counter() def is_time_over(self, LIMIT): return (perf_counter() - self.start_time) >= LIMIT def time_now(self): return (perf_counter() - self.start_time) ########################################### def main(DEBUG): tk = TimeKeeper() if DEBUG == True: LIMIT = 0.3 else: LIMIT = 0.3 Lin = list(map(int, input().split())) T = Lin[0] N = Lin[1] money = 2000000 # T = 52 ターン # N = 10 店の数 # 隠しデータ D = [] # 売れやすさ 0.5 <= d <1.5 for i in range(N): d = float(input()) D.append(d) Z = [] # 0.75 < z < 1.25 for i in range(T): z = list(map(float, input().split())) Z.append(z) p_book0 = 500 # 本の原価 p_adv = 500000 # 広告の単価 p_book1 = 1000 # 本の販売価格 Stot = 0 # 売上冊数 # 初期値 S = [0] * N P = [0] * N R = [0] * N prev = 0 # インタラクティブ for week in range(T): print(f'=== WEEK === {week}', file=sys.stderr, flush=True) # (あ) 出版社の行動を出力する x = 0 L = [0]*N Lprev = [0]*N # 広告をうつ if money > p_adv * 2: x = 1 cost = p_adv while cost < money//2: x += 1 cost = p_adv * 2**(x-1) print("2", x, flush=True) print("adv book", x, file=sys.stderr, flush=True) cost = p_adv * 2**(x-1) prev = 2 for i in range(N): Lprev[i] = max(0, S[i] * 3 - R[i]) # 1:本を発送 else: for i in range(N): if S[i] == 0 and R[i] == 0: L[i] = 1 else: # L[i] = max(0, S[i] * 3 - R[i]) if prev == 2: L[i] = Lprev[i] else: L[i] = max(0, S[i] * 3 - R[i]) print("1", *L, flush=True) print("send book", L, file=sys.stderr, flush=True) cost = sum(L) * p_book0 prev = 1 # (い) 売上部数などを入力する if DEBUG == False: money = int(input()) # 所持金 S = list(map(int, input().split())) # 各書店でこの週に売れた部数 P = list(map(int, input().split())) # 各書店での人気度 R = list(map(int, input().split())) # 各書店での在庫数 else: money -= cost for i in range(N): P[i] = max(-60, min(60, P[i]+x)) R[i] += L[i] S[i] = int(min(R[i], (R[i]**0.5) * (1.05 ** P[i]) * D[i] * Z[week][i])) money += S[i] * p_book1 Stot += S[i] if R[i] != 0 and S[i] >= 0.3 * R[i]: P[i] = min(60, P[i]+1) elif R[i] != 0 and S[i] < 0.1 * R[i]: P[i] = max(-60, P[i]-1) R[i] -= S[i] print(f"Stot: {Stot}", file=sys.stderr, flush=True) print(f"money: {money:,}", file=sys.stderr, flush=True) print(f"sell: {S}", file=sys.stderr, flush=True) print(f"popular: {P}", file=sys.stderr, flush=True) print(f"remain: {R}", file=sys.stderr, flush=True) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Debug mode') parser.add_argument('--debug', action='store_true', help='Enable debug mode') args = parser.parse_args() main(args.debug)