結果
| 問題 | No.580 旅館の予約計画 |
| ユーザー |
CELICA
|
| 提出日時 | 2020-10-09 21:02:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,158 bytes |
| コンパイル時間 | 1,686 ms |
| コンパイル使用メモリ | 177,748 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 07:55:22 |
| 合計ジャッジ時間 | 3,056 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<pair<int, int> > v(m);
for (auto&& it : v)
{
string e[4];
for (auto&& it2 : e)
cin >> it2;
it.first = stoi(e[0]) * 24 * 60 + stoi(e[1].substr(0, 2)) * 60 + stoi(e[1].substr(3, 2));
it.second = stoi(e[2]) * 24 * 60 + stoi(e[3].substr(0, 2)) * 60 + stoi(e[3].substr(3, 2));
}
sort(v.begin(), v.end(),
[](auto const& lhs, auto const& rhs)
{
return lhs.first < rhs.first
|| ((lhs.first == rhs.first) && (lhs.second < rhs.second));
});
int res{ 0 };
multiset<int> co;
for (const auto& it : v)
{
for (auto itco = co.begin(); itco != co.end();)
{
if (*itco < it.first)
itco = co.erase(itco);
else if (*itco >= it.first)
break;
}
if ((int)co.size() == n)
{
auto itco = --co.end();
if (*itco > it.second)
{
co.erase(itco);
co.insert(it.second);
}
}
else if ((int)co.size() < n)
{
co.insert(it.second);
++res;
}
}
cout << res << "\n";
return 0;
}
CELICA