結果
| 問題 | No.674 n連勤 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-21 16:01:50 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 932 bytes |
| 記録 | |
| コンパイル時間 | 1,379 ms |
| コンパイル使用メモリ | 222,192 KB |
| 実行使用メモリ | 6,784 KB |
| 最終ジャッジ日時 | 2026-06-14 16:18:46 |
| 合計ジャッジ時間 | 2,522 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 9 |
ソースコード
#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({l-1,INF});
if(it!=Il.end() && (it->first)<=r){
lint tl,tr; tie(tl,tr)=*it;
r=max(r,tr);
Sz.erase(Sz.find(tr-tl));
Il.erase(it);
Ir.erase({tr,tl});
continue;
}
}
{
auto it=Ir.upper_bound({l,-INF});
if(it!=Ir.end() && (it->second)<=r){
lint tl,tr; tie(tr,tl)=*it;
l=min(l,tl);
Sz.erase(Sz.find(tr-tl));
Ir.erase(it);
Il.erase({tl,tr});
continue;
}
}
break;
}
Sz.emplace(r-l);
Il.emplace(l,r);
Ir.emplace(r,l);
printf("%lld\n",*Sz.rbegin());
}
return 0;
}