結果

問題 No.580 旅館の予約計画
ユーザー 梧桐
提出日時 2026-03-22 21:28:02
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,093 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 651 ms
コンパイル使用メモリ 94,336 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-22 21:28:11
合計ジャッジ時間 6,142 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 16 RE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int, int> PII;

const int N = 110;

int n, m, dp[N], ans;
PII ti[N];

int main() {
    // freopen("hotel.in", "r", stdin);
    // freopen("hotel.out", "w", stdout);

    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        int d1, d2;
        string s1, s2;
        cin >> d1 >> s1 >> d2 >> s2;
        int h1 = (s1[0] - '0') * 10 + s1[1] - '0';
        int h2 = (s2[0] - '0') * 10 + s2[1] - '0';
        int m1 = (s1[3] - '0') * 10 + s1[4] - '0';
        int m2 = (s2[3] - '0') * 10 + s2[4] - '0';
        ti[i].first = d1 * 1440 + h1 * 60 + m1;
        ti[i].second = d2 * 1440 + h2 * 60 + m2;
    }

    sort(ti + 1, ti + m + 1);

    dp[1] = 1;
    ans = 1;
    for (int i = 1; i <= m; ++i) {
        for (int j = i + 1; j <= m; ++j) {
            if (ti[j].first >= ti[i].second + 1) {
                dp[j] = max(dp[j], dp[i] + 1);
                ans = max(ans, dp[j]);
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}
0