結果
問題 |
No.580 旅館の予約計画
|
ユーザー |
|
提出日時 | 2017-11-03 15:23:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 2,370 ms |
コンパイル使用メモリ | 200,736 KB |
最終ジャッジ日時 | 2025-01-05 03:42:06 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int MAXN = 100; const int MAXM = 1000; int N, M; int S[MAXM], T[MAXM]; int tord[MAXM]; signed main() { ios::sync_with_stdio(false); cin >> N >> M; for (int i = 0; i < M; ++i) { int d, h, m; char c; cin >> d >> h >> c >> m; S[i] = d * 24 * 60 + h * 60 + m; cin >> d >> h >> c >> m; T[i] = d * 24 * 60 + h * 60 + m + 1; tord[i] = i; } sort(tord, tord + M, [&] (int i, int j) { return T[i] < T[j]; }); multiset<int> bag; for (int i = 0; i < N; ++i) { bag.emplace(-1); } int ans = 0; for (int i = 0; i < M; ++i) { auto it = bag.upper_bound(S[tord[i]]); if (it == bag.begin()) continue; ++ans; bag.erase(--it); bag.emplace(T[tord[i]]); } cout << ans << endl; return 0; }