結果
問題 |
No.5017 Tool-assisted Shooting
|
ユーザー |
|
提出日時 | 2023-07-16 18:42:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 704 ms / 2,000 ms |
コード長 | 2,908 bytes |
コンパイル時間 | 464 ms |
コンパイル使用メモリ | 87,352 KB |
実行使用メモリ | 109,544 KB |
スコア | 3,149,739 |
平均クエリ数 | 924.60 |
最終ジャッジ日時 | 2023-07-16 18:44:35 |
合計ジャッジ時間 | 68,473 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
from collections import deque import random import argparse parser = argparse.ArgumentParser() parser.add_argument('--local', action='store_true') args = parser.parse_args() if args.local: P = list(map(int, input().split())) D = [deque() for _ in range(25)] my_x = 12 my_lv = 1 my_p = 0 dir = ["S", "R", "L"] turn = 0 while turn<1000: N = int(input()) if N==-1: break HPX = [list(map(int, input().split())) for _ in range(N)] #敵を移動 for x in range(25): for i in range(len(D[x])): # y D[x][i][0] -= 1 if len(D[x])>0 and D[x][0][0]<0: D[x].popleft() #新たな敵 for h, p, x in HPX: D[x].append([59, h, p, h]) #自機の移動を決定 maxhp = 0 max_x = -1 for x1 in range(25): if len(D[x1])==0: continue y1, h1, p1, ini1 = D[x1][0] #破壊可能か? trn1 = h1//my_lv + (1 if h1%my_lv else 0) sa1 = (x1-my_x)%25 if sa1==0: pass elif sa1<=12: trn1+=(sa1-1) else: trn1+=(sa1-13) if y1-trn1<1: continue #破壊可能 tmp = (p1)/(trn1) if maxhp<tmp: maxhp = tmp max_x = x1 tmp_lv = 1 + (my_p+p1)//100 for x2 in range(25): if len(D[x2])==0: continue if x1==x2 and len(D[x2])<=1: continue i = 1 if x1==x2 else 0 y2, h2, p2, ini2 = D[x2][i] #破壊可能か? trn2 = h2//tmp_lv + (1 if h2%tmp_lv else 0) sa2 = (x2-x1)%25 if sa2==0: pass elif sa2<=12: trn2+=(sa2-1) else: trn2+=(sa2-13) if y2-trn1-trn2<1: continue #破壊可能 #tmp = p/h tmp = (p1+p2)/(trn1+trn2) if maxhp<tmp: maxhp = tmp max_x = x1 if max_x==-1: if my_x<12: d = 1 elif my_x>12: d = -1 else: d = 0 else: sa = (max_x-my_x)%25 if sa==0: d = 0 elif sa<=12: d = 1 else: d = -1 #移動先に敵がいるか? nx = (my_x+d)%25 lp = 0 while lp<3 and len(D[nx])>0 and D[nx][0][0]<=1: #移動先に敵がいる if d==0: d = 1 if random.randint(0, 1) else -1 else: d = 0 nx = (my_x+d)%25 lp+=1 #自機を移動 print(dir[d], flush=True) my_x = (my_x+d)%25 #攻撃 if len(D[my_x])>0: y, h, p, ini = D[my_x][0] D[my_x][0][1] -= my_lv if D[my_x][0][1]<=0: my_p += p my_lv = 1 + my_p//100 D[my_x].popleft() turn += 1