結果

問題 No.674 n連勤
ユーザー ama_nukoama_nuko
提出日時 2018-07-13 17:55:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,167 bytes
コンパイル時間 1,063 ms
コンパイル使用メモリ 103,492 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 05:49:17
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
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 WA -
testcase_12 WA -
testcase_13 AC 71 ms
5,376 KB
testcase_14 AC 76 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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_;
        P y = *(range.upper_bound(r));

        if(x.second + 1 >= r.first){
            r.first = x.first;
            range.erase(x);
        }
        if(y.first <= r.second + 1){
            r.second = y.second;
            range.erase(y);
        }
        range.insert(r);

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