結果

問題 No.674 n連勤
ユーザー Toshiyuki Oike
提出日時 2018-04-19 16:35:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 662 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 63,112 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 04:51:14
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "vector"
#include "algorithm"

#define Q_MAX 30005

using namespace std;

typedef long long llint;

typedef struct Work {
    llint s;
    llint e;
} work;

llint D, Q;
vector<work> plans;


int main() {

    cin >> D >> Q;

    llint t_max = 0;
    for (int i = 0; i < Q; i++) {
        llint s, e;
        bool flag = true;
        cin >> s >> e;

        for (auto itr = plans.begin(); itr != plans.end(); ++itr) {
            if (itr->s <= e + 1 && itr->e >= s - 1) {
                // マージ可能
                s = min(s, itr->s);
                e = max(e, itr->e);
                itr = plans.erase(itr);
                itr--;
                // cout << s << " " << e << endl;
            }
        }

        work w;
        w.s = s;
        w.e = e;
        plans.push_back(w);
        t_max = max(t_max, e - s + 1);

        cout << t_max << endl;
    }

}
0