結果

問題 No.168 ものさし
ユーザー titiatitia
提出日時 2022-04-25 00:04:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 358 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 87,476 KB
実行使用メモリ 81,592 KB
最終ジャッジ日時 2023-09-08 18:04:47
合計ジャッジ時間 5,774 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 198 ms
79,756 KB
testcase_01 AC 79 ms
71,800 KB
testcase_02 AC 73 ms
71,864 KB
testcase_03 AC 74 ms
71,552 KB
testcase_04 AC 75 ms
71,668 KB
testcase_05 AC 75 ms
71,752 KB
testcase_06 AC 76 ms
71,616 KB
testcase_07 AC 75 ms
71,676 KB
testcase_08 AC 76 ms
71,788 KB
testcase_09 AC 112 ms
78,084 KB
testcase_10 AC 133 ms
78,496 KB
testcase_11 AC 196 ms
79,436 KB
testcase_12 AC 300 ms
81,012 KB
testcase_13 AC 346 ms
80,624 KB
testcase_14 AC 340 ms
80,584 KB
testcase_15 AC 74 ms
71,704 KB
testcase_16 AC 98 ms
76,884 KB
testcase_17 AC 116 ms
78,280 KB
testcase_18 AC 141 ms
78,584 KB
testcase_19 AC 335 ms
81,452 KB
testcase_20 AC 358 ms
81,552 KB
testcase_21 AC 326 ms
80,304 KB
testcase_22 AC 353 ms
81,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

N=int(input())
P=[tuple(map(int,input().split())) for i in range(N)]

DP=[1<<60]*N
DP[0]=0

Q=[(0,0)]

while Q:
    dis,x=heapq.heappop(Q)

    if DP[x]!=dis:
        continue

    a,b=P[x]

    for i in range(N):
        c,d=P[i]

        d=(a-c)**2+(b-d)**2

        yy=int(d**(1/2))
        score=0

        for j in range(yy-5,yy+5):
            if j<=0:
                continue
            if j*j>=d:
                score=j
                break
        if DP[i]>max(score,DP[x]):
            DP[i]=max(score,DP[x])
            heapq.heappush(Q,(DP[i],i))

print((DP[-1]+9)//10*10)
0