結果

問題 No.1557 Binary Variable
ユーザー homer12homer12
提出日時 2021-06-25 22:06:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,780 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 207,516 KB
実行使用メモリ 9,176 KB
最終ジャッジ日時 2023-09-07 14:32:42
合計ジャッジ時間 6,581 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
7,544 KB
testcase_01 AC 59 ms
8,312 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 63 ms
8,052 KB
testcase_05 AC 62 ms
7,628 KB
testcase_06 AC 61 ms
8,336 KB
testcase_07 AC 62 ms
8,152 KB
testcase_08 AC 66 ms
8,676 KB
testcase_09 AC 66 ms
8,840 KB
testcase_10 AC 69 ms
7,988 KB
testcase_11 AC 67 ms
7,784 KB
testcase_12 AC 65 ms
9,176 KB
testcase_13 AC 68 ms
7,440 KB
testcase_14 AC 69 ms
8,056 KB
testcase_15 AC 68 ms
7,520 KB
testcase_16 AC 70 ms
8,408 KB
testcase_17 AC 69 ms
8,248 KB
testcase_18 AC 68 ms
7,788 KB
testcase_19 AC 72 ms
7,388 KB
testcase_20 AC 72 ms
8,784 KB
testcase_21 AC 71 ms
8,520 KB
testcase_22 AC 72 ms
8,144 KB
testcase_23 AC 72 ms
7,720 KB
testcase_24 AC 73 ms
8,776 KB
testcase_25 AC 73 ms
7,472 KB
testcase_26 AC 76 ms
8,580 KB
testcase_27 AC 74 ms
7,992 KB
testcase_28 AC 75 ms
7,724 KB
testcase_29 AC 77 ms
7,344 KB
testcase_30 AC 77 ms
7,520 KB
testcase_31 AC 78 ms
8,152 KB
testcase_32 AC 76 ms
8,052 KB
testcase_33 AC 71 ms
8,768 KB
testcase_34 AC 1 ms
4,384 KB
testcase_35 AC 2 ms
4,384 KB
testcase_36 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using iPair = pair<int,int>;
using lPair = pair<ll, ll>;
using ivector = vector<int>;
using lvector = vector<ll>;
using istack = stack<int>;
using iqueue = queue<int>;
using ivv = vector<vector<int>>;
using lvv = vector<vector<ll>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
vector<iPair> dir = {{1,0}, {-1,0}, {0,1}, {0,-1}};
#define dump(x) cout << #x << " = " << (x) << endl
#define ALL(x) begin(x),end(x)
#define rep(i,s,e) for(ll i=(s), i_stop=(e); i<i_stop; ++i)
#define repRev(i,s,e) for(ll i=(e)-1, i_stop=(s); i>=i_stop; --i)
#define range(i,s,n) for(ll i=(s), i_stop=(s)+(n); i<i_stop; ++i)
#define rangeRev(i,s,n) for(ll i=(s), i_stop=(s)-(n); i>i_stop; --i)
#define foreach(x,container) for(auto &&x:container)
template<typename S, typename T> bool chmax(T& a, S b) {b = (T)b; if(a<b) {a=b;return true;} return false;}
template<typename S, typename T> bool chmin(T& a, S b) {b = (T)b; if(a>b) {a=b;return true;} return false;}
template<typename T> void printArr(vector<T> &arr){
    for(auto &x:arr) {cout << x << " ";} cout << endl;
}

// =====================================================>

bool compare(const lPair &a, const lPair &b) {
    if(a.second == b.second) return a.first < b.first;
    return a.second < b.second;
}

void solve() {
    ll n,m; cin>>n>>m;
    vector<lPair> vec;
    range(i,1,m) {ll x,y; cin>>x>>y; vec.emplace_back(x, y);}
    sort(vec.begin(), vec.end(), compare);
    ll t = 0; ll ans = 0;
    for(ll i = 0; i < m; ++i) {
        if(vec[i].first > t) {
            t = vec[i].second;
            ++ans;
        } 
    }
    cout << n-ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}
0