結果

問題 No.674 n連勤
ユーザー kotatsugamekotatsugame
提出日時 2020-03-05 09:23:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 73,500 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 02:06:57
合計ジャッジ時間 1,887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 71 ms
5,376 KB
testcase_14 AC 67 ms
5,376 KB
testcase_15 AC 66 ms
5,376 KB
testcase_16 AC 80 ms
5,376 KB
testcase_17 AC 80 ms
5,376 KB
testcase_18 AC 71 ms
5,376 KB
testcase_19 AC 70 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;
long D;
int Q;
set<pair<long,long> >S;
main()
{
	cin>>D>>Q;
	long ans=0;
	for(int i=0;i<Q;i++)
	{
		long A,B;cin>>A>>B;
		B++;
		pair<long,long>now=make_pair(A,B);
		set<pair<long,long> >::iterator it=S.lower_bound(make_pair(A,-1L));
		while(it!=S.end()&&it->first<=now.second)
		{
			if(now.second<it->second)now.second=it->second;
			it=S.erase(it);
		}
		while(it!=S.begin())
		{
			it--;
			if(now.first>it->second)break;
			if(now.second<it->second)now.second=it->second;
			if(now.first>it->first)now.first=it->first;
			it=S.erase(it);
		}
		if(ans<now.second-now.first)ans=now.second-now.first;
		S.insert(now);
		cout<<ans<<endl;
	}
}
0