結果

問題 No.580 旅館の予約計画
ユーザー Mister
提出日時 2020-08-18 09:00:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 83,844 KB
最終ジャッジ日時 2025-01-13 02:53:43
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

int input() {
    int d, h, m;
    {
        char tmp;
        std::cin >> d >> h >> tmp >> m;
    }

    return ((d - 2) * 24 + h) * 60 + m;
}

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<std::pair<int, int>> ps(m);
    for (auto& [r, l] : ps) {
        l = input();
        r = input() + 1;
    }
    std::sort(ps.begin(), ps.end());

    std::vector<int> ts(n, 0);
    int ans = 0;
    for (auto [r, l] : ps) {
        int i = -1;
        for (int j = 0; j < n; ++j) {
            if (ts[j] <= l) i = j;
        }
        if (i == -1) continue;

        ts[i] = r;
        ++ans;
        std::sort(ts.begin(), ts.end());
    }

    std::cout << ans << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0