結果

問題 No.966 引き算をして門松列(その1)
ユーザー 0w10w1
提出日時 2020-01-16 14:33:35
言語 Ruby
(3.3.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 11,308 KB
実行使用メモリ 15,412 KB
最終ジャッジ日時 2023-09-05 23:08:23
合計ジャッジ時間 1,686 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,232 KB
testcase_01 AC 74 ms
15,088 KB
testcase_02 AC 73 ms
15,032 KB
testcase_03 AC 76 ms
15,088 KB
testcase_04 AC 160 ms
15,412 KB
testcase_05 AC 168 ms
15,156 KB
testcase_06 AC 183 ms
15,364 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

t = gets.to_i
t.times do
  a, b, c = gets.split.map &:to_i

  d = [[0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1]].map { |r|
    ps = (0...3).map { |i| r.find_index { |v| v == i } }
    vs = (0...3).map { |i| [a, b, c][ps[i]] }
    next Float::INFINITY if vs[1] < 2 || vs[2] < 3
    [vs[1] - (vs[2] - 1), 0].max + [vs[0] - ([vs[1], vs[2] - 1].min - 1), 0].max
  } .min

  d = -1 if d == Float::INFINITY
  puts d
end
0