結果

問題 No.580 旅館の予約計画
ユーザー maimai
提出日時 2017-10-25 10:02:56
言語 Ruby
(3.3.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 11,292 KB
実行使用メモリ 16,024 KB
最終ジャッジ日時 2023-08-14 00:51:11
合計ジャッジ時間 5,091 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,028 KB
testcase_01 AC 80 ms
15,028 KB
testcase_02 AC 79 ms
15,160 KB
testcase_03 AC 81 ms
15,112 KB
testcase_04 AC 81 ms
15,164 KB
testcase_05 AC 81 ms
15,064 KB
testcase_06 AC 81 ms
15,188 KB
testcase_07 AC 82 ms
15,264 KB
testcase_08 AC 80 ms
15,148 KB
testcase_09 AC 82 ms
15,232 KB
testcase_10 AC 81 ms
15,276 KB
testcase_11 AC 82 ms
15,236 KB
testcase_12 AC 84 ms
15,412 KB
testcase_13 AC 84 ms
15,172 KB
testcase_14 AC 86 ms
15,228 KB
testcase_15 AC 98 ms
15,768 KB
testcase_16 AC 92 ms
15,884 KB
testcase_17 AC 93 ms
15,940 KB
testcase_18 AC 92 ms
16,024 KB
testcase_19 AC 97 ms
15,880 KB
testcase_20 AC 92 ms
15,556 KB
testcase_21 AC 91 ms
15,720 KB
testcase_22 AC 88 ms
15,560 KB
testcase_23 AC 91 ms
15,360 KB
testcase_24 AC 91 ms
15,584 KB
testcase_25 AC 91 ms
15,448 KB
testcase_26 AC 82 ms
15,188 KB
testcase_27 AC 81 ms
15,304 KB
testcase_28 AC 80 ms
15,224 KB
testcase_29 AC 81 ms
15,032 KB
testcase_30 AC 90 ms
15,300 KB
testcase_31 AC 93 ms
15,484 KB
testcase_32 AC 90 ms
15,476 KB
testcase_33 AC 95 ms
15,912 KB
testcase_34 AC 90 ms
15,340 KB
testcase_35 AC 78 ms
15,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def schedule_problem_legacy(brackets)
    bb = brackets.sort
    ans = []
    bb.each do |b|
        ans << b if ans.empty? || ans.last[0] < b[1]
    end
    return ans
end


def schedule_problem(brackets, slotsize = 1)
    bb = brackets.sort
    ans = []
    slots = [-1]*slotsize
    bb.each do |b|
        able = slots.select{|t| t < b[1] }.max
        if able
            slots[slots.index(able)] = b[0]
            ans << b
        end
    end
    return ans
end




n, m = gets.split.map(&:to_i)
brackets = []
m.times do
    z = gets.scan(/(\d+) (\d+):(\d+)/)
    brackets << z.map{|t| t.map!(&:to_i); t[0]*1440+t[1]*60+t[2]}.reverse
end

ans = schedule_problem(brackets, n).size
p ans
0