結果

問題 No.965 門松列が嫌い
ユーザー tamarontamaron
提出日時 2020-01-13 22:09:20
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 1,097 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 11,300 KB
実行使用メモリ 15,504 KB
最終ジャッジ日時 2023-08-24 16:55:29
合計ジャッジ時間 1,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:14: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:45: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

T=gets.to_i
T.times do |i|
    a,b,c,x,y,z=gets.split.map(&:to_i)
    if [a,b,c].max<=2 || (a==1 && a==b) || (b==1 && b==c) || (c==1 && c==a)
        puts -1
        next
    end
    x,z=z,x if c<a
    a,c=c,a if c<a
    u=[x,z].min
    v=[x,z].max
    if a==b && b==c
        if a<=2
            puts -1
        elsif 3<=a
            puts 2*u+v
        end
    elsif a==b && b<c
        if 3<=b
            puts [2*x+(c-b+2)*z,y].min
        else
            puts y
        end
    elsif a<b && b==c
        if a+1==b
            puts [2*y,2*z].min
        else
            if a==1
                puts z
            else
                puts [z,(b-a+1)*y].min
            end
        end
    elsif a==c && c<b
        puts u
    elsif b<a && a==c
        if b+1==a
            puts 2*u
        else
            puts u
        end
    elsif a<b && b<c
        if a==1
            if b==2
                puts -1
            else
                puts (c-b+1)*z
            end
        else 
            puts [(b-a+1)*y,(c-b+1)*z].min
        end
    else
        puts 0
    end
end
            

0