結果

問題 No.707 書道
ユーザー maimai
提出日時 2018-06-29 22:29:42
言語 Ruby
(3.3.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,504 KB
実行使用メモリ 15,408 KB
最終ジャッジ日時 2023-09-13 15:21:48
合計ジャッジ時間 2,040 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,280 KB
testcase_01 AC 87 ms
15,052 KB
testcase_02 AC 118 ms
15,264 KB
testcase_03 AC 84 ms
15,084 KB
testcase_04 AC 83 ms
15,228 KB
testcase_05 AC 171 ms
15,320 KB
testcase_06 AC 216 ms
15,120 KB
testcase_07 AC 259 ms
15,408 KB
testcase_08 AC 89 ms
15,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i); end

H,W = ascan

F = H.times.map{gets.chomp}

best = 1e18

check = lambda do |cy, cx|
    d = 0
    H.times do |y|
        W.times do |x|
            d += Math.sqrt((y-cy)**2+(x-cx)**2) if F[y][x] == '1'
        end
    end
    best = [d, best].min
end

H.times do |cy|
    check.call(cy, -1)
    check.call(cy, W)
end
W.times do |cx|
    check.call(-1, cx)
    check.call(H, cx)
end


p best
0