algo — C++23 日本語リファレンス GitHub

test/yukicoder/0674.test.cpp

AC · 最終更新 2026-07-24 · GitHub

問題: https://yukicoder.me/problems/no/674

依存するヘッダ(1)
実装
// competitive-verifier: PROBLEM https://yukicoder.me/problems/no/674
#include <algorithm>
#include <cstdint>
#include <iostream>
#include "data_structure/range_set.hpp"

int main(void) {
    std::int64_t d;
    int q;
    std::cin >> d >> q;
    range_set<std::int64_t> rst;
    std::int64_t ans = 0;
    while (q--) {
        std::int64_t l, r;
        std::cin >> l >> r;
        auto [x, y] = rst.insert(l, r + 1);
        ans = std::max(ans, y - x);
        std::cout << ans << '\n';
    }

    return 0;
}