結果

問題 No.859 路線A、路線B、路線C
ユーザー koi_kotyakoi_kotya
提出日時 2019-08-09 21:41:27
言語 Ruby
(3.2.2)
結果
AC  
実行時間 90 ms / 1,000 ms
コード長 416 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 15,308 KB
最終ジャッジ日時 2023-09-26 17:34:11
合計ジャッジ時間 2,266 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
15,308 KB
testcase_01 AC 84 ms
15,100 KB
testcase_02 AC 85 ms
15,068 KB
testcase_03 AC 85 ms
15,252 KB
testcase_04 AC 87 ms
15,144 KB
testcase_05 AC 85 ms
15,044 KB
testcase_06 AC 86 ms
15,120 KB
testcase_07 AC 83 ms
15,308 KB
testcase_08 AC 83 ms
15,040 KB
testcase_09 AC 82 ms
15,152 KB
testcase_10 AC 83 ms
15,144 KB
testcase_11 AC 82 ms
15,244 KB
testcase_12 AC 83 ms
15,104 KB
testcase_13 AC 83 ms
15,076 KB
testcase_14 AC 83 ms
15,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

x,y,z = gets.split.map(&:to_i)
a = Hash.new
a["A"] = x
a["B"] = y
a["C"] = z
s = []
t = []
s[0],t[0] = gets.split
s[1],t[1] = gets.split
t[0] = t[0].to_i
t[1] = t[1].to_i
ans = 10**10
u = [t[0]-1,a[s[0]]-t[0]]
v = [t[1]-1,a[s[1]]-t[1]]
ans = (t[0]-t[1]).abs if (s[0] == s[1]) 
2.times do |i|
    2.times do |j|
        r = u[i]+v[j]+1
        r += [x,y,z].min if i != j
        ans = [ans,r].min
    end
end
puts ans
0