結果

問題 No.674 n連勤
ユーザー furafura
提出日時 2020-10-21 15:41:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 993 bytes
コンパイル時間 3,297 ms
コンパイル使用メモリ 210,524 KB
実行使用メモリ 5,276 KB
最終ジャッジ日時 2023-09-28 14:13:43
合計ジャッジ時間 3,673 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 15 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

template<class T> struct interval{
	T l,r;
	interval(){}
	interval(const T& l,const T& r):l(l),r(r){}
	bool operator<(const interval& I)const{ return make_tuple(l,r)<make_tuple(I.l,I.r); }
};

int main(){
	int q; scanf("%*lld%d",&q);

	multiset<lint> Sz;
	set<interval<lint>> I;
	rep(_,q){
		interval<lint> J; scanf("%lld%lld",&J.l,&J.r); J.r++;

		auto del=[&](auto it){
			Sz.erase(Sz.find((it->r)-(it->l)));
			I.erase(it);
		};
		auto add=[&](auto J){
			Sz.emplace(J.r-J.l);
			I.emplace(J);
		};

		while(1){
			auto it=I.upper_bound(interval<lint>(J.l-1,INF));
			if(it==I.end() || J.r<(it->l)) break;
			J.r=max(J.r,it->r);
			del(it);
		}
		while(1){
			auto it=I.lower_bound(J);
			if(it==I.begin()) break;
			--it;
			if((it->r)<J.l) break;
			J.l=min(J.l,it->l);
			del(it);
		}
		add(J);

		printf("%lld\n",*Sz.rbegin());
	}

	return 0;
}
0