結果

問題 No.5017 Tool-assisted Shooting
ユーザー miya145592
提出日時 2023-07-16 17:13:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 502 ms / 2,000 ms
コード長 2,112 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 108,304 KB
スコア 2,269,413
平均クエリ数 875.36
最終ジャッジ日時 2023-07-16 17:13:54
合計ジャッジ時間 51,970 ms
ジャッジサーバーID
(参考情報)
judge11 / judge17
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

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])

    #自機の移動を決定
    maxhp = 0
    max_x = -1
    for x in range(25):
        if len(D[x])==0:
            continue
        y, h, p = D[x][0]
        #破壊可能か?
        trn = h//my_lv + (1 if h%my_lv else 0)
        sa = (x-my_x)%25
        if sa==0:
            pass
        elif sa<=12:
            trn+=(sa-1)
        else:
            trn+=(sa-13)
        if y-trn<1:
            continue
        #破壊可能
        tmp = p/h
        if maxhp<tmp:
            maxhp = tmp
            max_x = x

    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 = 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
0