結果
問題 | No.674 n連勤 |
ユーザー |
![]() |
提出日時 | 2018-10-26 17:34:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 1,127 bytes |
コンパイル時間 | 874 ms |
コンパイル使用メモリ | 93,264 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-19 06:22:50 |
合計ジャッジ時間 | 2,613 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <cstdio> #include <cstring> #include <string> #include <iostream> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <unordered_map> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; const ll INF=1e18+1; int main() { ll d; int q; cin>>d>>q; set<P> st; multiset<ll> stl; for(int i=0; i<q; i++){ ll a, b; cin>>a>>b; ll l, r; auto itr1=st.lower_bound(P(a, -1)); if(itr1==st.begin()){ l=a; }else{ auto itr4=itr1; itr4--; if((*itr4).second<a-1){ l=a; }else{ l=(*itr4).first; itr1=itr4; } } auto itr2=st.lower_bound(P(b+2, -1)); auto itr3=itr2; if(itr3==st.begin()){ r=b; }else{ itr3--; r=max(b, (*itr3).second); } for(auto itr=itr1; itr!=itr2; itr++){ stl.erase(stl.lower_bound((itr->second)-(itr->first)+1)); } st.erase(itr1, itr2); st.insert(P(l, r)); stl.insert(r-l+1); auto itr0=stl.end(); itr0--; cout<<*itr0<<endl; } return 0; }