結果

問題 No.1995 CHIKA Road
ユーザー MasKoaTSMasKoaTS
提出日時 2022-06-24 15:51:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 2,089 bytes
コンパイル時間 4,071 ms
コンパイル使用メモリ 260,304 KB
実行使用メモリ 9,164 KB
最終ジャッジ日時 2024-04-25 21:45:50
合計ジャッジ時間 7,139 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 8 ms
6,944 KB
testcase_07 AC 21 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 66 ms
8,652 KB
testcase_11 AC 102 ms
8,776 KB
testcase_12 AC 108 ms
8,652 KB
testcase_13 AC 34 ms
6,944 KB
testcase_14 AC 36 ms
6,940 KB
testcase_15 AC 87 ms
9,164 KB
testcase_16 AC 11 ms
6,940 KB
testcase_17 AC 47 ms
6,940 KB
testcase_18 AC 79 ms
8,780 KB
testcase_19 AC 82 ms
8,652 KB
testcase_20 AC 43 ms
6,940 KB
testcase_21 AC 41 ms
6,944 KB
testcase_22 AC 76 ms
8,520 KB
testcase_23 AC 23 ms
6,940 KB
testcase_24 AC 67 ms
8,520 KB
testcase_25 AC 14 ms
6,944 KB
testcase_26 AC 28 ms
6,940 KB
testcase_27 AC 64 ms
8,396 KB
testcase_28 AC 40 ms
6,940 KB
testcase_29 AC 83 ms
8,652 KB
testcase_30 AC 14 ms
6,940 KB
testcase_31 AC 7 ms
6,940 KB
testcase_32 AC 17 ms
6,940 KB
testcase_33 AC 63 ms
8,524 KB
testcase_34 AC 8 ms
6,940 KB
testcase_35 AC 26 ms
6,944 KB
testcase_36 AC 30 ms
6,944 KB
testcase_37 AC 74 ms
8,524 KB
testcase_38 AC 50 ms
6,940 KB
testcase_39 AC 7 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <math.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define print(n) cout << (n) << endl
#define fprint(n) cout << setprecision(16) << (n) << endl
#define ceil_div(a, b) (((a) - 1) / (b) + 1)
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define itrep(itr, st) for (auto itr = st.begin(); itr != st.end(); itr++)
#define ite(i, a) for (auto& i : a)
#define all(x) x.begin(), x.end()
#define lb(A, x) (lower_bound(all(A), x) - A.begin())
#define ub(A, x) (upper_bound(all(A), x) - A.begin())
using str = string;
using ll = long long;
using Pair = pair<int, int>;
using mint = modint1000000007;
using Mint = modint998244353;
template <class T>	using V = vector<T>;
template <class T>	using VV = V<V<T> >;
template <class T>	using PQ = priority_queue<T, V<T>, greater<T> >;
template <class T>	using PQR = priority_queue<T>;
template <class T>	using BIT = fenwick_tree<T>;
const ll INF = 4611686018427387903;
const int inf = 2147483647;
const ll mod = 1000000007;
const ll MOD = 998244353;
template <class T>  inline V<T> getList(int n) { V<T> res(n); rep(i, 0, n) { cin >> res[i]; }return res; }
template <class T>  inline VV<T> getGrid(int m, int n) { VV<T> res(m, V<T>(n)); rep(i, 0, m) { res[i] = getList<T>(n); }return res; }
template <class T> inline void prints(V<T>& vec) { if (vec.size() == 0)return; cout << vec[0];	rep(i, 1, vec.size()) { cout << ' ' << vec[i]; } cout << '\n'; }
inline V<int> dtois(string& s) { V<int> vec = {}; ite(e, s) { vec.push_back(e - '0'); } return vec; }
inline V<int> atois(string& s) { V<int> vec = {}; ite(e, s) { vec.push_back(e - 'a'); } return vec; }
inline V<int> Atois(string& s) { V<int> vec = {}; ite(e, s) { vec.push_back(e - 'A'); } return vec; }


int main(void) {
	int n, m;	cin >> n >> m;

	VV<int> plan = {};
	rep(i, 0, m) {
		int a, b;	cin >> a >> b;
		plan.push_back({ b,a });
	}
	sort(all(plan));

	int now = 0, ans = 2 * (n - 1);
	rep(i, 0, m) {
		int a = plan[i][1], b = plan[i][0];
		if (now > a) {
			continue;
		}
		now = b;
		ans--;
	}
	print(ans);

	return 0;
}
0