結果

問題 No.674 n連勤
コンテスト
ユーザー CELICA
提出日時 2020-10-15 22:29:52
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 751 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,751 ms
コンパイル使用メモリ 192,856 KB
実行使用メモリ 10,312 KB
最終ジャッジ日時 2026-04-03 02:19:05
合計ジャッジ時間 3,227 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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