結果
| 問題 |
No.674 n連勤
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2018-04-14 01:38:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,116 bytes |
| コンパイル時間 | 1,586 ms |
| コンパイル使用メモリ | 173,524 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-26 22:05:11 |
| 合計ジャッジ時間 | 3,055 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
struct RNG {
ll l, r;
bool operator<(const RNG& a) const {
return r < a.r;
}
};
class MaxRange {
ll max_range;
set<RNG> rngs;
public:
MaxRange():max_range(0){}
void add(const RNG& rng){
ll nl = rng.l, nr = rng.r;
auto bgn = rngs.lower_bound((RNG){nl-1,nl-1});
auto it = bgn;
for(; it != rngs.end(); it++){
if(it->l < rng.r){
nl = min(nl, it->l);
nr = max(nr, it->r);
}else{
break;
}
}
rngs.erase(bgn, it);
rngs.insert((RNG){nl,nr});
max_range = max(max_range, nr+1-nl);
}
ll get_max(){
return max_range;
}
};
int main(){
ll D;
int Q;
cin >> D >> Q;
MaxRange mr;
rep(i,Q){
ll A, B;
cin >> A >> B;
mr.add((RNG){A,B});
cout << mr.get_max() << endl;
}
return 0;
}
どらら