結果

問題 No.967 引き算をして門松列(その2)
ユーザー tamarontamaron
提出日時 2020-01-13 21:46:13
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 917 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 11,356 KB
実行使用メモリ 15,544 KB
最終ジャッジ日時 2023-08-24 16:03:48
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,144 KB
testcase_01 AC 78 ms
15,100 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:37: 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
        puts y
    elsif a<b && b==c
        if a+1==b
            puts [2*y,2*z].min
        else
            puts z
        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