結果

問題 No.190 Dry Wet Moist
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-04-22 00:29:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 31,084 KB
最終ジャッジ日時 2023-08-26 23:17:19
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,168 KB
testcase_01 AC 80 ms
15,196 KB
testcase_02 AC 79 ms
15,072 KB
testcase_03 AC 79 ms
15,180 KB
testcase_04 AC 79 ms
15,108 KB
testcase_05 AC 71 ms
15,212 KB
testcase_06 AC 72 ms
15,248 KB
testcase_07 AC 72 ms
15,168 KB
testcase_08 AC 73 ms
15,256 KB
testcase_09 AC 70 ms
15,268 KB
testcase_10 AC 72 ms
15,124 KB
testcase_11 AC 72 ms
15,256 KB
testcase_12 AC 149 ms
23,880 KB
testcase_13 AC 163 ms
26,048 KB
testcase_14 AC 150 ms
23,612 KB
testcase_15 AC 175 ms
27,000 KB
testcase_16 AC 208 ms
30,280 KB
testcase_17 AC 92 ms
16,660 KB
testcase_18 AC 130 ms
21,952 KB
testcase_19 AC 188 ms
29,976 KB
testcase_20 AC 148 ms
25,176 KB
testcase_21 AC 81 ms
15,936 KB
testcase_22 AC 205 ms
30,896 KB
testcase_23 AC 193 ms
30,924 KB
testcase_24 AC 212 ms
31,084 KB
testcase_25 AC 73 ms
15,280 KB
testcase_26 AC 72 ms
15,120 KB
testcase_27 AC 159 ms
25,308 KB
testcase_28 AC 111 ms
19,576 KB
testcase_29 AC 120 ms
20,840 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

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
            right -=1
        end
    end
    return count
end
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
            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


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

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



0