結果
問題 | No.674 n連勤 |
ユーザー | rokahikou1 |
提出日時 | 2021-02-26 12:53:13 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,688 bytes |
コンパイル時間 | 1,798 ms |
コンパイル使用メモリ | 172,672 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-10 03:27:45 |
合計ジャッジ時間 | 3,622 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | WA | - |
testcase_11 | AC | 8 ms
6,940 KB |
testcase_12 | WA | - |
testcase_13 | AC | 71 ms
6,940 KB |
testcase_14 | AC | 93 ms
6,940 KB |
testcase_15 | WA | - |
testcase_16 | AC | 96 ms
6,940 KB |
testcase_17 | AC | 95 ms
6,944 KB |
testcase_18 | WA | - |
testcase_19 | AC | 76 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> template <typename T> class IntervalSet : std::set<std::pair<T, T>> { private: const T INF = std::numeric_limits<T>::max() - 65; bool isMergeAdjacent; public: /** * @brief Construct a new Interval Set object * * @param f if merge adjacent interval */ IntervalSet(bool f) : isMergeAdjacent(f) { this->emplace(-INF - 1, -INF); this->emplace(INF, INF + 1); } auto get(T p) const { auto it = this->upper_bound({p, INF}); if(it == this->begin() || (--it)->second < p) return this->end(); return it; } void insert(T l, T r) { auto it = std::prev(this->lower_bound({l, r})); if(it->first <= l && l - isMergeAdjacent <= it->second) { l = std::min(l, it->first); r = std::max(r, it->first); } it = this->lower_bound({l, r}); while(1) { if(l <= it->first && it->first <= r) { r = std::max(r, it->second); it = this->erase(it); } else break; } this->emplace(l, r); } void remove(T l, T r) {} bool same(T p, T q) const { auto it = get(p); return it != this->end() && it->first <= q && q <= it->second; } }; int main() { long long d, q; std::cin >> d >> q; IntervalSet<long long> st(true); long long res = 0; for(int i = 0; i < q; i++) { long long x, y; std::cin >> x >> y; y++; st.insert(x, y); auto it = st.get(x); res = std::max(it->second - it->first, res); std::cout << res << std::endl; } }