結果
問題 | No.674 n連勤 |
ユーザー |
![]() |
提出日時 | 2021-04-30 22:37:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 843 bytes |
コンパイル時間 | 2,056 ms |
コンパイル使用メモリ | 199,772 KB |
最終ジャッジ日時 | 2025-01-21 03:51:38 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>#define REP(i, s, n) for (int i = s; i < (int)(n); i++)#define ALL(a) a.begin(), a.end()#define MOD 1000000007using namespace std;using ll = long long;int main() {ll D; int Q; cin >> D >> Q;set<pair<ll, ll>> S;S.insert({-(1LL << 60), -(1LL << 60)});S.insert({1LL << 60, 1LL << 60});ll consecutive = 0;while (Q--) {ll a, b; cin >> a >> b; b++; // [a, b)auto itr = prev(S.lower_bound({a, 0}));if (itr->first <= a && a <= itr->second) a = itr->first;for (auto itr = S.lower_bound({a, 0}); a <= itr->first && itr->first <= b; ) {b = max(b, itr->second);itr = S.erase(itr);}S.insert({a, b});consecutive = max(consecutive, b - a);cout << consecutive << endl;}return 0;}