結果
問題 | No.674 n連勤 |
ユーザー |
![]() |
提出日時 | 2023-11-28 00:14:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 3,919 bytes |
コンパイル時間 | 2,224 ms |
コンパイル使用メモリ | 199,520 KB |
最終ジャッジ日時 | 2025-02-18 02:11:03 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;// #include <atcoder/all>// #include <atcoder/modint>// #include <atcoder/math>// #include <atcoder/segtree>// #include <atcoder/lazysegtree>// #include <atcoder/dsu>// #include <atcoder/scc>// using namespace atcoder;// #pragma GCC target("avx2")// #pragma GCC optimize("O3")// #pragma GCC optimize("unroll-loops")typedef long long int ll;typedef unsigned long long ull;typedef long double ld;typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef vector<vll> vvll;typedef vector<vvll> vvvll;typedef vector<pll> vpll;typedef vector<vpll> vvpll;typedef vector<bool> vb;typedef vector<vb> vvb;typedef vector<double> vd;typedef vector<vd> vvd;typedef priority_queue<pll, vpll, function<bool(pll,pll)> > pqpll;typedef priority_queue<ll, vll, function<bool(pll,pll)> > pqll;struct edge{ ll to, cost; edge(ll e_to,ll e_cost): to(e_to), cost(e_cost){} };typedef vector<vector<edge>> Graph;#define rep(i,a,n) for(ll i = a;i < n;i++)#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)#define LINF (1LL << 60)#define INF (1 << 30)#define fs first#define sc second#define EPS (ld)1e-10#define ALL(a) a.begin(), a.end()#define tcheck(a) if((clock() - start)/(ld)CLOCKS_PER_SEC >= a) break#define debug(s) cout << #s << endl#define debugval(x) cout << #x" = " << x << endltemplate<typename T> ll sz(vector<T> &pos){ return (ll)pos.size(); }template<typename T> ll sz(priority_queue<T, vector<T> > &que) {return (ll)que.size(); }template<typename T> ll sz(priority_queue<T, vector<T>, greater<T> > &que) {return (ll)que.size(); }ll sz(string &s) {return (ll)s.size(); }template<typename T> void chmin(T &a, T b) { if(a > b) a = b; }template<typename T> void chmax(T &a, T b) { if(a < b) a = b; }// __int128_t gcd(__int128_t a, __int128_t b){ return ((!b) ? a : gcd(b,a%b)); }ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }ll dx[4] = {0,-1,0,1},dy[4] = {-1,0,1,0};// ll dx[8] = {0,-1,-1,-1,0,1,1,1},dy[8] = {-1,-1,0,1,1,1,0,-1};inline bool isinside(ll i,ll n){ return (i < n && i >= 0); }struct range_set {set<pair<ll, ll>> st;range_set(){st.emplace(-(1ll << 61), -(1ll << 61));st.emplace((1ll << 61), (1ll << 61));}void insert(ll x){ insert(x,x+1); }ll insert(ll l, ll r){ // [l,r)assert(l < r);auto it = st.lower_bound(make_pair(l,r)); it--;if(it->first <= l && l <= it->second){l = min(l, it->first);r = max(r, it->second);st.erase(it);}it = st.lower_bound(make_pair(l,r));while(l <= it->first && it->first <= r){r = max(r, it->second);it = st.erase(it);}st.emplace(l,r);return r-l;}ll count(ll x){auto it = st.lower_bound(make_pair(x+1,x+1));it--;return (it->first <= x && x < it->second);}void erase(ll x){ erase(x, x+1); }void erase(ll l, ll r){ // [l,r)assert(l < r);ll x = l, y = r;auto it = st.lower_bound(make_pair(l,r)); it--;if(it->first <= l && l <= it->second){l = min(l, it->first);r = max(r, it->second);st.erase(it);}it = st.lower_bound(make_pair(l,r));while(l <= it->first && it->first <= r){r = max(r, it->second);it = st.erase(it);}if(l < x) st.emplace(l,x);if(y < r) st.emplace(y,r);}ll mex(){auto it = st.lower_bound(make_pair(1,1));it--;return (it->first <= 0 && 0 < it->second ? it->second : 0ll );}};int main(){ll d,q;cin >> d >> q;ll ans = 0;range_set rs;rep(i,0,q){ll a,b; cin >> a >> b;chmax(ans, rs.insert(a,b+1));cout << ans << endl;}}