結果
| 問題 | No.674 n連勤 | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2025-10-19 18:11:25 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 22 ms / 2,000 ms | 
| コード長 | 933 bytes | 
| コンパイル時間 | 1,736 ms | 
| コンパイル使用メモリ | 168,096 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-19 18:11:28 | 
| 合計ジャッジ時間 | 2,922 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
# include <bits/stdc++.h>
# define int long long
# define FILE(x) freopen(x ".in", "r", stdin); freopen(x ".out", "w", stdout);
using namespace std;
int d, q;
map < int, int > cnt;
int ans;
void solve()
{
    cin >> d >> q;
    while (q --)
    {
        int a, b;
        cin >> a >> b;
        auto it = cnt.lower_bound(a);
        if (it != cnt.begin())
        {
            auto it2 = it;
            -- it2;
            if (it2 -> second >= a - 1) it = it2;
        }
        while (it != cnt.end() && it -> first <= b + 1)
        {
            a = min(a, it -> first);
            b = max(b, it -> second);
            auto to_erase = it;
            ++ it;
            cnt.erase(to_erase);
        }
        cnt[a] = b;
        ans = max(ans, b - a + 1);
        cout << ans << '\n';
    }
}
signed main()
{
    ios :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int T = 1;
    while (T --) solve();
    return 0;
}
            
            
            
        