結果

問題 No.674 n連勤
コンテスト
ユーザー vjudge1
提出日時 2026-03-15 23:41:22
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 953 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,273 ms
コンパイル使用メモリ 187,484 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-15 23:41:54
合計ジャッジ時間 2,830 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 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()
{
    FILE("onduty");
    ios :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int T = 1;
    while (T --) solve();
    return 0;
}
0