結果

問題 No.190 Dry Wet Moist
ユーザー 小指が強い人小指が強い人
提出日時 2016-01-11 21:41:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,404 KB
実行使用メモリ 29,516 KB
最終ジャッジ日時 2023-08-27 01:30:08
合計ジャッジ時間 6,352 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,064 KB
testcase_01 AC 81 ms
15,268 KB
testcase_02 AC 78 ms
15,296 KB
testcase_03 AC 75 ms
15,060 KB
testcase_04 AC 79 ms
15,196 KB
testcase_05 AC 75 ms
15,064 KB
testcase_06 AC 76 ms
15,252 KB
testcase_07 AC 76 ms
15,312 KB
testcase_08 AC 76 ms
15,136 KB
testcase_09 AC 73 ms
14,992 KB
testcase_10 AC 76 ms
15,068 KB
testcase_11 AC 79 ms
15,060 KB
testcase_12 AC 148 ms
23,076 KB
testcase_13 AC 167 ms
24,904 KB
testcase_14 AC 146 ms
22,676 KB
testcase_15 AC 168 ms
25,748 KB
testcase_16 AC 219 ms
28,628 KB
testcase_17 AC 104 ms
16,436 KB
testcase_18 AC 144 ms
21,232 KB
testcase_19 AC 218 ms
28,232 KB
testcase_20 AC 173 ms
24,416 KB
testcase_21 AC 93 ms
15,888 KB
testcase_22 AC 203 ms
29,428 KB
testcase_23 AC 206 ms
29,508 KB
testcase_24 AC 206 ms
29,516 KB
testcase_25 AC 86 ms
15,248 KB
testcase_26 AC 85 ms
15,084 KB
testcase_27 AC 182 ms
24,304 KB
testcase_28 AC 129 ms
19,124 KB
testcase_29 AC 139 ms
20,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i * 2
a = gets.split.map(&:to_i)
a.sort!
i = 0
j = n - 1
dry = 0
while i < j && a[i] < 0 do
    if a[i] + a[j] < 0
        dry += 1
        i += 1
        j -= 1
    else
        j -= 1
    end
end
i = 0
j = n - 1
moist = 0
while i < j && a[i] <= 0 && a[j] >= 0 do
    if -a[i] == a[j]
        moist += 1
        i += 1
        j -= 1
    elsif -a[i] > a[j]
        i += 1
    else
        j -= 1
    end
end
i = 0
j = n - 1
wet = 0
while i < j && a[j] > 0 do
    if a[i] + a[j] > 0
        wet += 1
        i += 1
        j -= 1
    else
        i += 1
    end
end
print dry, " ", wet, " " , moist, "\n"
0