結果

問題 No.674 n連勤
ユーザー ei1333333ei1333333
提出日時 2017-04-05 02:00:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 151,744 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-12 13:14:54
合計ジャッジ時間 3,075 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 60;

int main()
{
  int64 D, Q, ret = 0;

  cin >> D >> Q;

  set< pair< int64, int64 > > st;
  st.emplace(-INF, -INF);
  st.emplace(INF, INF);

  for(int i = 0; i < Q; i++) {
    int64 A, B;
    cin >> A >> B;
    st.emplace(A, B);

    auto p = --st.lower_bound({A, -1});
    if(A - 1 <= p->second) A = p->first;
    else ++p;
    while(B + 1 >= p->first) B = max(B, p->second), p = st.erase(p);
    st.emplace(A, B);

    ret = max(ret, B - A + 1);
    cout << ret << endl;
  }
}
0