結果

問題 No.580 旅館の予約計画
ユーザー CELICACELICA
提出日時 2020-10-09 21:02:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,158 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 176,780 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 13:53:33
合計ジャッジ時間 3,305 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0