結果
問題 |
No.674 n連勤
|
ユーザー |
|
提出日時 | 2025-08-31 23:17:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 3,659 ms |
コンパイル使用メモリ | 283,764 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-31 23:17:37 |
合計ジャッジ時間 | 5,198 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < n; i++) int main(){ ll d; cin >> d; int n; cin >> n; set<pair<ll, ll>> st; ll const inf = 2e18; st.emplace(-inf, -inf); st.emplace(inf, inf); ll ans = 0; for(int i = 0; i < n; i++){ ll x, y; cin >> x >> y; y++; auto it = st.lower_bound(pair(x, y)); it--; if((*it).first <= x && x <= (*it).second){ x = min(x, (*it).first); y = max(y, (*it).second); st.erase(it); } it = st.lower_bound(pair(x, y)); while(true){ if(x <= (*it).first && (*it).first <= y){ y = max(y, (*it).second); it = st.erase(it); }else{ break; } } st.emplace(x, y); ans = max(ans, y-x); cout << ans << endl; } }