結果

問題 No.168 ものさし
ユーザー roiti46roiti46
提出日時 2015-03-20 00:36:21
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,442 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 77,796 KB
実行使用メモリ 90,584 KB
最終ジャッジ日時 2023-08-25 20:45:28
合計ジャッジ時間 9,720 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 281 ms
84,000 KB
testcase_01 AC 82 ms
78,868 KB
testcase_02 AC 81 ms
78,268 KB
testcase_03 AC 80 ms
78,472 KB
testcase_04 AC 79 ms
78,472 KB
testcase_05 AC 81 ms
78,624 KB
testcase_06 AC 81 ms
78,476 KB
testcase_07 AC 82 ms
78,516 KB
testcase_08 AC 80 ms
78,596 KB
testcase_09 AC 106 ms
80,296 KB
testcase_10 AC 112 ms
80,472 KB
testcase_11 AC 256 ms
83,472 KB
testcase_12 AC 565 ms
87,252 KB
testcase_13 AC 729 ms
89,724 KB
testcase_14 AC 747 ms
89,904 KB
testcase_15 AC 80 ms
78,276 KB
testcase_16 AC 100 ms
80,412 KB
testcase_17 AC 107 ms
80,268 KB
testcase_18 AC 131 ms
81,100 KB
testcase_19 AC 962 ms
89,848 KB
testcase_20 AC 1,442 ms
90,584 KB
testcase_21 AC 682 ms
89,696 KB
testcase_22 AC 1,100 ms
90,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
inf = 10**12
def dist(i,j):
    x1,y1 = XY[i]
    x2,y2 = XY[j]
    d = (x1-x2)**2+(y1-y2)**2
    if d-int(d**0.5)**2 > 0:
        return int(d**0.5)/10*10+10
    else:
        if int(d**0.5)%10 == 0:
            return int(d**0.5)
        else:
            return int(d**0.5)/10*10+10

N = int(raw_input())
XY = [map(int,raw_input().split()) for i in xrange(N)]
D = [[dist(i,j) for i in xrange(N)] for j in xrange(N)]
ans = inf
que = deque([[0,0]])
maxd = [inf]*N
maxd[0] = 0
while que:
    i,d = que.popleft()
    if i == N-1:
        ans = min(ans,d)
        continue
    for j in xrange(N):
        if i == j: continue
        if D[i][j] < maxd[j] and d < maxd[j]:
            maxd[j] = max(d,D[i][j])
            que.append([j,maxd[j]])
print ans
0