結果
| 問題 |
No.674 n連勤
|
| コンテスト | |
| ユーザー |
ks115
|
| 提出日時 | 2021-04-30 22:22:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 806 bytes |
| コンパイル時間 | 8,936 ms |
| コンパイル使用メモリ | 197,952 KB |
| 最終ジャッジ日時 | 2025-01-21 03:22:41 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 6 |
ソースコード
#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 1000000007
using namespace std;
using ll = long long;
int main() {
ll D; int Q; cin >> D >> Q;
set<pair<ll, ll>> S;
S.insert({-1, -1});
S.insert({D, D});
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;
}
ks115