結果
| 問題 | No.674 n連勤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-04-13 23:21:56 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 87 ms / 2,000 ms | 
| コード長 | 1,202 bytes | 
| コンパイル時間 | 958 ms | 
| コンパイル使用メモリ | 107,264 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-26 21:55:02 | 
| 合計ジャッジ時間 | 2,395 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
int main()
{
    long long d;
    int q;
    cin >> d >> q;
    long long ans = 0;
    set<pair<long long, long long> > s;
    while(--q >= 0){
        long long a, b;
        cin >> a >> b;
        ++ b;
        auto it = s.lower_bound(make_pair(a, -1));
        while(it != s.end()){
            if(b < it->first)
                break;
            b = max(b, it->second);
            it = s.erase(it);
        }
        while(it != s.begin()){
            -- it;
            if(it->second < a)
                break;
            a = min(a, it->first);
            b = max(b, it->second);
            it = s.erase(it);
        }
        s.insert(make_pair(a, b));
        ans = max(ans, b - a);
        cout << ans << endl;
    }
    return 0;
}
            
            
            
        