結果
| 問題 |
No.674 n連勤
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2022-06-21 01:24:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 758 bytes |
| コンパイル時間 | 2,228 ms |
| コンパイル使用メモリ | 200,660 KB |
| 最終ジャッジ日時 | 2025-01-29 23:34:20 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
constexpr int64_t inf = 2e18;
int64_t d, q;
cin >> d >> q;
map<int64_t, int64_t> mp;
mp[-inf] = -inf;
mp[inf] = inf;
int64_t ans = 0;
for (int i = 0; i < q; i++) {
int64_t a, b;
cin >> a >> b;
int64_t l = a, r = b;
auto it = mp.upper_bound(a);
it--;
if (it->first < a and it->second >= a - 1) {
l = it->first;
it = mp.erase(it);
} else {
it++;
}
while (it->first <= b + 1) {
r = max(r, it->second);
it = mp.erase(it);
}
mp[l] = r;
ans = max(ans, r - l + 1);
cout << ans << endl;
}
return 0;
}
trineutron