結果
| 問題 | No.674 n連勤 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-14 01:10:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 876 bytes |
| 記録 | |
| コンパイル時間 | 1,965 ms |
| コンパイル使用メモリ | 199,176 KB |
| 最終ジャッジ日時 | 2025-01-15 07:07:24 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll d; cin >> d; ll res=0;
int n; cin >> n;
set<pair<ll,ll>> st;
st.insert(make_pair(-2e18,-2e18));
st.insert(make_pair(2e18,2e18));
for(int i=0;i<n;i++){
ll x,y; cin >> x >> y; y++;
auto it=st.lower_bound(make_pair(x,y)); it--;
if(it->first <= x and x <= it->second){
x=min(x,it->first); y=max(y,it->second);
st.erase(it);
}
it=st.lower_bound(make_pair(x,y));
while(1){
if(x <= it->first and it->first <= y){
y=max(y,it->second);
it=st.erase(it);
}
else break;
}
st.insert(make_pair(x,y));
res=max(res,y-x);
printf("%lld\n",res);
}
}