結果

問題 No.1557 Binary Variable
ユーザー miscalcmiscalc
提出日時 2021-06-25 22:02:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 170,128 KB
実行使用メモリ 6,512 KB
最終ジャッジ日時 2023-09-07 14:31:41
合計ジャッジ時間 8,159 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
6,176 KB
testcase_01 AC 137 ms
6,204 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 106 ms
6,104 KB
testcase_05 AC 106 ms
6,512 KB
testcase_06 AC 100 ms
6,268 KB
testcase_07 AC 103 ms
6,260 KB
testcase_08 AC 115 ms
6,404 KB
testcase_09 AC 115 ms
6,284 KB
testcase_10 AC 127 ms
6,332 KB
testcase_11 AC 126 ms
6,280 KB
testcase_12 AC 114 ms
6,228 KB
testcase_13 AC 126 ms
6,148 KB
testcase_14 AC 138 ms
6,332 KB
testcase_15 AC 127 ms
6,176 KB
testcase_16 AC 136 ms
6,220 KB
testcase_17 AC 136 ms
6,156 KB
testcase_18 AC 135 ms
6,224 KB
testcase_19 AC 148 ms
6,108 KB
testcase_20 AC 145 ms
6,212 KB
testcase_21 AC 146 ms
6,260 KB
testcase_22 AC 146 ms
6,264 KB
testcase_23 AC 146 ms
6,468 KB
testcase_24 AC 152 ms
6,152 KB
testcase_25 AC 152 ms
6,272 KB
testcase_26 AC 155 ms
6,224 KB
testcase_27 AC 155 ms
6,232 KB
testcase_28 AC 159 ms
6,156 KB
testcase_29 AC 170 ms
6,484 KB
testcase_30 AC 165 ms
6,228 KB
testcase_31 AC 170 ms
6,220 KB
testcase_32 AC 168 ms
6,096 KB
testcase_33 AC 145 ms
6,100 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tlll = tuple<ll, ll, ll>;
//constexpr ll MOD = 1e9 + 7;
constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<pll> RL(M);
  for (ll i = 0; i < M; i++)
  {
    cin >> RL.at(i).second >> RL.at(i).first;
  }

  sort(RL.begin(), RL.end());

  ll r0 = 0;
  ll ans = N;
  for (ll i = 0; i < M; i++)
  {
    pll rl = RL.at(i);
    ll r = rl.first, l = rl.second;
    if (!(l <= r0 && r0 <= r))
    {
      r0 = r;
      ans--;
    }
  }
  cout << ans << endl;
}
0