結果

問題 No.580 旅館の予約計画
ユーザー nebukuro09nebukuro09
提出日時 2018-06-12 13:56:45
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 165,296 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 20:23:28
合計ジャッジ時間 3,992 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 4 ms
4,376 KB
testcase_31 AC 4 ms
4,376 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 4 ms
4,376 KB
testcase_34 AC 5 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto s = readln.split;
    auto N = s[0].to!int;
    auto M = s[1].to!int;
    auto S = new Tuple!(int, int)[](M);
    foreach (i; 0..M) {
        s = readln.split;
        int d1 = s[0].to!int;
        int h1 = s[1].split(":")[0].to!int;
        int m1 = s[1].split(":")[1].to!int;
        int d2 = s[2].to!int;
        int h2 = s[3].split(":")[0].to!int;
        int m2 = s[3].split(":")[1].to!int;
        S[i] = tuple(d1*60*24+h1*60+m1, d2*60*24+h2*60+m2);
    }
    S.sort!"a[1] == b[1] ? a[0] < b[0] : a[1] < b[1]";

    int ans = 0;
    auto rbt = new RedBlackTree!(int, "a < b", true)();

    foreach (seg; S) {
        if (rbt.empty) {
            ans += 1;
            rbt.insert(seg[1]);
        } else {
            auto lb = rbt.lowerBound(seg[0]);
            if (!lb.empty) {
                ans += 1;
                int x = lb.back;
                rbt.removeKey(x);
                rbt.insert(seg[1]);
            } else if (rbt.length < N) {
                ans += 1;
                rbt.insert(seg[1]);
            }
        }
    }

    ans.writeln;
}
0