結果
問題 |
No.674 n連勤
|
ユーザー |
|
提出日時 | 2020-10-13 20:50:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 934 bytes |
コンパイル時間 | 2,433 ms |
コンパイル使用メモリ | 198,740 KB |
最終ジャッジ日時 | 2025-01-15 07:06:09 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; int q; cin >> q; set<pair<ll,ll>> st; st.insert(make_pair(-2e18,-2e18)); st.insert(make_pair(2e18,2e18)); ll res=0; while(q--){ ll a,b; cin >> a >> b; b++; auto it=st.lower_bound(make_pair(a,b)); it--; if(it->first<=a and a<=it->second){ if(it->first>=0)a=min(a,it->first); if(it->second<=d)b=max(b,it->second); st.erase(it); } it=st.lower_bound(make_pair(a,b)); while(1){ if(a<=it->first and it->first<=b){ b=max(b,it->second); it=st.erase(it); } else{ break; } } st.insert(make_pair(a,b)); res=max(res,b-a); printf("%lld\n",res); } }