結果
問題 | No.674 n連勤 |
ユーザー |
![]() |
提出日時 | 2023-05-17 15:53:28 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 930 bytes |
コンパイル時間 | 5,435 ms |
コンパイル使用メモリ | 145,264 KB |
実行使用メモリ | 14,592 KB |
最終ジャッジ日時 | 2024-12-15 09:53:38 |
合計ジャッジ時間 | 18,021 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 TLE * 5 |
ソースコード
#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 = 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;}