結果

問題 No.674 n連勤
ユーザー kotatsugamekotatsugame
提出日時 2020-03-05 09:09:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 646 bytes
コンパイル時間 962 ms
コンパイル使用メモリ 74,296 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 02:06:20
合計ジャッジ時間 2,637 ms
ジャッジサーバーID
(参考情報)
judge1 / 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 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 73 ms
5,376 KB
testcase_14 AC 78 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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,-1));
		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.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