結果

問題 No.674 n連勤
コンテスト
ユーザー vjudge1
提出日時 2025-10-21 12:14:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 167,812 KB
実行使用メモリ 13,204 KB
最終ジャッジ日時 2025-10-21 12:14:12
合計ジャッジ時間 3,776 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000010;
const int mod=998244353;
int n,m;
int ans;
int l[N],r[N];
set<int>s;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	int tot=0;
	for(int i=1;i<=m;i++){
		cin>>l[i]>>r[i];
		s.insert(l[i]-1);
		s.insert(l[i]);
		s.insert(r[i]);
		s.insert(r[i]+1);
	}
	for(int i=1;i<=m;i++){
		while(!s.empty()){
			set<int>::iterator it=s.lower_bound(l[i]);
			if(*it>r[i])break;
			s.erase(it);
		}
		set<int>::iterator R=s.lower_bound(l[i]);
		set<int>::iterator L=R;
		--L;
		ans=max(ans,*R-*L-1);
		cout<<ans<<"\n";
	}
	return 0;
}
/*

*/
0