結果
問題 | No.1557 Binary Variable |
ユーザー |
![]() |
提出日時 | 2021-06-25 22:38:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 769 bytes |
コンパイル時間 | 1,649 ms |
コンパイル使用メモリ | 173,996 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-06-25 08:40:57 |
合計ジャッジ時間 | 8,141 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<ll, ll> P;#define DUMP(x) cout << #x << " = " << (x) << endl;#define FOR(i, m, n) for (ll i = m; i < n; i++)#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)#define REP(i, n) FOR(i, 0, n)#define IREP(i, n) IFOR(i, 0, n)#define ALL(v) (v).begin(), (v).end()#define SZ(x) ll(x.size())int main() {ll n, m;cin >> n >> m;vector<ll> l(m), r(m);REP(i, m) { cin >> l[i] >> r[i]; }vector<ll> ord(m);iota(ALL(ord), 0);sort(ALL(ord), [&](ll i, ll j) { return r[i] < r[j]; });ll ans = n, p = -1;REP(ii, m) {ll i = ord[ii];ll cl = l[i], cr = r[i];if (cl <= p && p <= cr) {continue;}ans--;p = cr;}cout << ans << endl;}