結果
問題 |
No.580 旅館の予約計画
|
ユーザー |
|
提出日時 | 2019-10-25 09:36:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 76,032 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 05:22:02 |
合計ジャッジ時間 | 1,684 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include<iostream> #include<set> #include<vector> using namespace std; int main(){ int n, m; scanf("%d %d\n", &n, &m); vector<int> v[7*24*60]; auto f = [](int d, int h, int m)->int{ return (d-2)*24*60+h*60+m; }; while(m-- > 0){ int d1, h1, m1, d2, h2, m2; scanf("%d %d:%d %d %d:%d\n", &d1, &h1, &m1, &d2, &h2, &m2); int from = f(d1, h1, m1), to = f(d2, h2, m2); v[from].push_back(to); } int ans = 0; multiset<int> stay; for(int i = 0; i < 7*24*60; i++){ for(int j : v[i]) stay.insert(j); while(stay.size() > n) stay.erase(--stay.end()); while(!stay.empty() && *stay.begin() == i){ stay.erase(stay.begin()); ans++; } } cout << ans << endl; return 0; }