結果
問題 |
No.674 n連勤
|
ユーザー |
![]() |
提出日時 | 2023-05-17 15:57:21 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 1,852 ms |
コンパイル使用メモリ | 144,500 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-12-15 09:54:35 |
合計ジャッジ時間 | 2,697 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#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 = S.lower_bound(a); if (*it > b) break; S.erase(*it); } auto it = S.lower_bound(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; }