結果

問題 No.674 n連勤
ユーザー chocoruskchocorusk
提出日時 2018-10-26 17:34:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,127 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 92,980 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-08-12 07:34:02
合計ジャッジ時間 3,591 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 69 ms
4,380 KB
testcase_14 AC 72 ms
4,384 KB
testcase_15 AC 69 ms
4,380 KB
testcase_16 AC 95 ms
5,004 KB
testcase_17 AC 96 ms
5,088 KB
testcase_18 AC 88 ms
4,376 KB
testcase_19 AC 70 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0