結果

問題 No.674 n連勤
ユーザー CELICACELICA
提出日時 2020-10-15 22:29:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 174,848 KB
実行使用メモリ 10,148 KB
最終ジャッジ日時 2023-09-28 01:26:09
合計ジャッジ時間 3,905 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 15 ms
5,084 KB
testcase_14 AC 51 ms
9,116 KB
testcase_15 AC 34 ms
6,800 KB
testcase_16 AC 65 ms
10,148 KB
testcase_17 AC 64 ms
9,872 KB
testcase_18 AC 49 ms
7,172 KB
testcase_19 AC 63 ms
9,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;

template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
		a = b;
	return a < b;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll d, q;
	cin >> d >> q;
	vector<ll> a(q), b(q);
	set<ll> s;
	for (ll i = 0; i < q; ++i)
	{
		cin >> a[i] >> b[i];

		s.insert(a[i] - 1);
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(b[i] + 1);
	}

	stringstream ss;
	ll maxd{ 0 };
	for (int i = 0; i < q; ++i)
	{
		auto itb = s.lower_bound(a[i]);
		auto ite = s.upper_bound(b[i]);
		ite = s.erase(itb, ite);
		auto it = ite;
		chmax(maxd, *ite - *(--it) - 1);
		ss << maxd << "\n";
	}

	cout << ss.str();

	return 0;
}
0