結果

問題 No.1557 Binary Variable
ユーザー vimalvimal
提出日時 2021-06-26 04:43:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,345 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 171,888 KB
実行使用メモリ 20,932 KB
最終ジャッジ日時 2023-09-07 15:16:47
合計ジャッジ時間 7,125 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

//Macro Shorthands
#define F first
#define S second
#define f(i, n) for (ll i = 0; i <= n; i++)
#define rf(i, n) for (ll i = n; i >= 0; i--)
#define Cf(i, a, b) for (ll i = a; i <= b; i++)
#define Crf(i, b, a) for (ll i = b; i >= a; i--)
#define pb push_back
#define mp make_pair
#define z ((ll)1e9 + 7)
#define every(it, x) for (auto &it : x)
#define SET(it, x)     \
    for (auto &it : x) \
    {                  \
        cin >> it;     \
    }
#define ins insert
#define INF ((ll)1e18)
#define Test  \
    ll T;     \
    cin >> T; \
    while (T--)
#define all(v) v.begin(), v.end()
#define nline cout << endl
#define SZ(v) (ll) v.size()
#define pll pair<ll, ll>

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<pair<ll, ll>> vpll;
typedef set<ll> sll;
typedef set<string> sstr;
typedef set<pair<ll, ll>> spll;
typedef map<ll, ll> mllll;
typedef map<string, ll> mstrll;
typedef queue<ll> qll;
ll powMod(ll x, ll y)
{
    ll p = 1;
    while (y)
    {
        if (y % 2)
        {
            p = (p * x) % z;
        }
        y /= 2;
        x = (x * x) % z;
    }
    return p;
}
ll CpowMod(ll x, ll y, ll w)
{
    ll p = 1;
    while (y)
    {
        if (y % 2)
        {
            p = (p * x) % w;
        }
        y /= 2;
        x = (x * x) % w;
    }
    return p;
}
ll invMod(ll x) { return powMod(x, z - 2); }
ll CinvMod(ll x, ll w) { return CpowMod(x, w - 2, w); }
ll gcdd(ll a, ll b) { return b == 0 ? a : gcdd(b, a % b); }
const ll mod = 1e9 + 7;
bool cmp(pair<ll,ll>&a,pair<ll,ll>&b)
{
    if(a.first == b.first)
    {
        return a.second < b.second;
    }
    else{
        return a.first < a.second;
    }
    return false;
}
void call()
{
    ll n;cin >> n;
    ll  m ;cin >> m;
    vector<pair<ll,ll>>v(m);
    for(ll i =0 ;i < m;++i)
    {
        ll x,y;cin >> x  >> y;
        v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end(),cmp);
    ll ans=0;
    ll back=-1;
    for(ll i=0;i<v.size();++i)
    { 
       if(v[i].first < back)
       {
         back=max(back,v[i].second);
       }
       else{
           ans++;
       }
    }
    cout << n-ans<< endl;
}
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        call();
    }
}
0