結果

問題 No.112 ややこしい鶴亀算
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-12 00:05:13
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 466 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-10-11 15:40:34
合計ジャッジ時間 3,785 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,152 KB
testcase_01 AC 82 ms
15,020 KB
testcase_02 AC 85 ms
15,032 KB
testcase_03 AC 82 ms
15,316 KB
testcase_04 AC 82 ms
15,320 KB
testcase_05 AC 83 ms
15,036 KB
testcase_06 AC 84 ms
15,124 KB
testcase_07 AC 83 ms
15,308 KB
testcase_08 AC 84 ms
15,292 KB
testcase_09 AC 83 ms
15,248 KB
testcase_10 AC 84 ms
15,324 KB
testcase_11 AC 84 ms
15,136 KB
testcase_12 AC 83 ms
15,096 KB
testcase_13 AC 84 ms
15,048 KB
testcase_14 AC 83 ms
15,120 KB
testcase_15 AC 83 ms
15,096 KB
testcase_16 AC 83 ms
15,028 KB
testcase_17 AC 84 ms
15,152 KB
testcase_18 AC 85 ms
15,248 KB
testcase_19 AC 83 ms
15,148 KB
testcase_20 AC 83 ms
15,112 KB
testcase_21 AC 83 ms
15,160 KB
testcase_22 AC 84 ms
15,232 KB
testcase_23 AC 84 ms
15,320 KB
testcase_24 AC 84 ms
15,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:23: warning: `elsif' at the end of line without an expression
Main.rb:4: warning: assigned but unused variable - count
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map(&:to_i)
base = a[n - 1]
count = 0
b1 = 0
b2 = 0
b3 = 0
(n - 1).times do |i|
    if base - a[i] < 0
        b1 += 1
    elsif base - a[i] > 0
        b2 += 1
    else
        b3 += 1
    end
end
if b1 == 0 && b2 == 0
    if base == 2 * (n - 1)
        print n, " ", 0, "\n"
    else
        print 0, " ", n, "\n"
    end
elsif
    if b1 == 0
        print b3 + 1, " ", b2, "\n"
    else
        print b1, " ", b3 + 1, "\n"
    end
end
0