結果

問題 No.674 n連勤
ユーザー ama_nukoama_nuko
提出日時 2018-07-13 18:11:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 1,281 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 103,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 07:46:36
合計ジャッジ時間 2,760 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 8 ms
5,376 KB
testcase_13 AC 69 ms
5,376 KB
testcase_14 AC 77 ms
5,376 KB
testcase_15 AC 72 ms
5,376 KB
testcase_16 AC 90 ms
5,376 KB
testcase_17 AC 91 ms
5,376 KB
testcase_18 AC 82 ms
5,376 KB
testcase_19 AC 76 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e18;
const int MOD = 1e9+7;

signed main(){
    int d, q;
    cin >> d >> q;

    set<P> range;
    range.emplace(-INF-10, -INF-10);
    range.emplace(INF+10, INF+10);
    int ans = 0;
    rep(i, q){
        int a, b;
        cin >> a >> b;
        P r = make_pair(a, b);
        auto x_ = range.lower_bound(r);
        x_--;
        P x = *x_;

        if(x.second + 1 >= r.first){
            r.first = x.first;
            r.second = max(r.second, x.second);
            range.erase(x);
        }

        auto y_ = range.upper_bound(r);
        P y = *y_;
        while(y.first <= r.second + 1){
            r.second = max(r.second, y.second);
            y_ = range.erase(y_);
            y = *y_;
        }
        range.insert(r);

        int len = r.second - r.first + 1;
        if(ans < len){
            ans = len;
        }
        cout << ans << endl;
    }
    return 0;
}
0