結果

問題 No.674 n連勤
ユーザー fura
提出日時 2020-10-21 15:57:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 880 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 205,264 KB
最終ジャッジ日時 2025-01-15 12:14:25
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:22: warning: use of assignment suppression and length modifier together in gnu_scanf format [-Wformat=]
   14 |         int q; scanf("%*lld%d",&q);
      |                      ^~~~~~~~~
main.cpp:14:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         int q; scanf("%*lld%d",&q);
      |                ~~~~~^~~~~~~~~~~~~~
main.cpp:16:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 lint l,r; scanf("%lld%lld",&l,&r); r++;
      |                           ~~~~~^~~~~~~~~~~~~~~~~~

ソースコード

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;

int main(){
	set<pair<lint,lint>> Il,Ir; // 左端でソート, 右端でソート
	multiset<lint> Sz;

	int q; scanf("%*lld%d",&q);
	rep(_,q){
		lint l,r; scanf("%lld%lld",&l,&r); r++;

		while(1){
			auto it=Il.upper_bound(make_pair(l-1,INF));
			if(it==Il.end() || r<(it->first)) break;
			lint tl,tr; tie(tl,tr)=*it;
			r=max(r,tr);
			Sz.erase(Sz.find(tr-tl));
			Il.erase(it);
			Ir.erase({tr,tl});
		}
		while(1){
			auto it=Ir.upper_bound(make_pair(l,-INF));
			if(it==Ir.end() || r<(it->second)) break;
			lint tl,tr; tie(tr,tl)=*it;
			l=min(l,tl);
			Sz.erase(Sz.find(tr-tl));
			Ir.erase(it);
			Il.erase({tl,tr});
		}
		Sz.emplace(r-l);
		Il.emplace(l,r);
		Ir.emplace(r,l);

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

	return 0;
}
0