結果

問題 No.190 Dry Wet Moist
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-04-22 00:24:28
言語 Ruby
(3.3.0)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,368 KB
実行使用メモリ 31,104 KB
最終ジャッジ日時 2023-08-27 05:32:43
合計ジャッジ時間 5,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,184 KB
testcase_01 AC 82 ms
15,136 KB
testcase_02 AC 82 ms
15,212 KB
testcase_03 AC 82 ms
15,084 KB
testcase_04 AC 81 ms
15,132 KB
testcase_05 AC 83 ms
15,220 KB
testcase_06 AC 83 ms
15,172 KB
testcase_07 AC 86 ms
15,024 KB
testcase_08 AC 85 ms
15,088 KB
testcase_09 AC 83 ms
15,188 KB
testcase_10 AC 82 ms
15,132 KB
testcase_11 AC 82 ms
15,124 KB
testcase_12 AC 162 ms
24,012 KB
testcase_13 AC 179 ms
26,160 KB
testcase_14 AC 158 ms
23,528 KB
testcase_15 AC 184 ms
26,728 KB
testcase_16 AC 214 ms
30,156 KB
testcase_17 AC 99 ms
16,760 KB
testcase_18 AC 139 ms
21,960 KB
testcase_19 AC 211 ms
29,780 KB
testcase_20 AC 173 ms
25,196 KB
testcase_21 AC 91 ms
15,912 KB
testcase_22 AC 225 ms
30,848 KB
testcase_23 AC 216 ms
30,940 KB
testcase_24 AC 227 ms
31,104 KB
testcase_25 AC 82 ms
15,268 KB
testcase_26 AC 80 ms
15,300 KB
testcase_27 AC 176 ms
25,308 KB
testcase_28 AC 124 ms
19,624 KB
testcase_29 AC 132 ms
20,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
@as = gets.split.map(&:to_i).sort

def get_wet
    count = 0
    left = 0
    right = @as.length - 1
    while(left<right) do
        if(@as[left] + @as[right] < 0)
            count +=1
            left +=1
            right -=1
        else
            right -=1
        end
    end
    return count
end
def get_dry
    count = 0
    left = 0
    right = @as.length - 1
    while(left<right) do
        if(@as[left] + @as[right] > 0)
            count +=1
            left +=1
            right -=1
        else
            left +=1
        end
    end
    return count
end

def get_moist
    count = 0
    left = 0
    right = @as.length - 1
    while(left<right) do
        if(@as[left] + @as[right] == 0)
            count +=1
            left +=1
            right -=1
        elsif @as[left] + @as[right] <0
            left +=1
        else
            right -=1
        end
    end
    return count
end


wet = [get_wet,N].min
dry = [get_dry,N].min
moist = [get_moist,N].min

puts "#{wet} #{dry} #{moist}"



0