結果

問題 No.674 n連勤
ユーザー simansiman
提出日時 2023-05-17 15:49:45
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 948 bytes
コンパイル時間 7,170 ms
コンパイル使用メモリ 108,876 KB
実行使用メモリ 13,724 KB
最終ジャッジ日時 2023-08-21 19:30:19
合計ジャッジ時間 14,449 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 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,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 380 ms
4,380 KB
testcase_12 AC 389 ms
4,380 KB
testcase_13 AC 68 ms
4,384 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll D, Q;
  cin >> D >> Q;

  vector<ll> A(Q);
  vector<ll> B(Q);
  set<ll> S;

  for (int i = 0; i < Q; ++i) {
    cin >> A[i] >> B[i];

    S.insert(A[i] - 1);
    S.insert(A[i]);
    S.insert(B[i]);
    S.insert(B[i] + 1);
  }

  ll ans = 0;

  for (int i = 0; i < Q; ++i) {
    ll a = A[i];
    ll b = B[i];

    while (true) {
      auto it = lower_bound(S.begin(), S.end(), a);
      if (*it > b) break;

      S.erase(*it);
    }

    auto it = lower_bound(S.begin(), S.end(), a);
    ll end_at = *it;
    --it;
    ll start_at = *it;

    // fprintf(stderr, "(%lld, %lld)\n", start_at, end_at);
    ans = max(ans, end_at - start_at - 1);
    cout << ans << endl;
  }

  return 0;
}
0