Submission #4417208


Source Code Expand

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL N, M; cin >> N >> M;
	vector<PLL>a(M);
	FOR(i, 0, M) {
		cin >> a[i].first >> a[i].second;
	}
	sort(ALL(a), [](const PLL&a, const PLL&b) {
		if (a.second != b.second) {
			return a.second < b.second;
		}
		else {
			return a.first > b.first;
		}
	});
	LL s = 0; LL ans = 0;
	FOR(i, 0, M) {
		if (s <= a[i].first) {
			s = a[i].second;
			ans++;
		}
	}

	std::cout << ans << endl;

	return 0;
}

Submission Info

Submission Time
Task D - Islands War
User Yang33
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1662 Byte
Status AC
Exec Time 25 ms
Memory 1792 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 44
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All 0_small_0, 0_small_1, 0_small_10, 0_small_2, 0_small_3, 0_small_4, 0_small_5, 0_small_6, 0_small_7, 0_small_8, 0_small_9, 1_rand_0, 1_rand_1, 1_rand_2, 1_rand_3, 1_rand_4, 1_rand_5, 1_rand_6, 1_rand_7, 1_rand_8, 1_rand_9, 2_max_0, 2_max_1, 2_max_2, 2_max_3, 2_max_4, 2_max_5, 2_max_6, 2_max_7, 2_max_8, 2_max_9, 3_nosub_0, 3_nosub_1, 3_nosub_2, 3_nosub_3, 3_nosub_4, 3_nosub_5, 3_nosub_6, 3_nosub_7, 3_nosub_8, 3_nosub_9, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_small_0 AC 1 ms 256 KiB
0_small_1 AC 1 ms 256 KiB
0_small_10 AC 1 ms 256 KiB
0_small_2 AC 1 ms 256 KiB
0_small_3 AC 1 ms 256 KiB
0_small_4 AC 1 ms 256 KiB
0_small_5 AC 1 ms 256 KiB
0_small_6 AC 1 ms 256 KiB
0_small_7 AC 1 ms 256 KiB
0_small_8 AC 1 ms 256 KiB
0_small_9 AC 1 ms 256 KiB
1_rand_0 AC 2 ms 384 KiB
1_rand_1 AC 11 ms 896 KiB
1_rand_2 AC 22 ms 1664 KiB
1_rand_3 AC 23 ms 1664 KiB
1_rand_4 AC 4 ms 512 KiB
1_rand_5 AC 20 ms 1536 KiB
1_rand_6 AC 11 ms 896 KiB
1_rand_7 AC 19 ms 1408 KiB
1_rand_8 AC 8 ms 768 KiB
1_rand_9 AC 22 ms 1664 KiB
2_max_0 AC 25 ms 1792 KiB
2_max_1 AC 25 ms 1792 KiB
2_max_2 AC 25 ms 1792 KiB
2_max_3 AC 25 ms 1792 KiB
2_max_4 AC 25 ms 1792 KiB
2_max_5 AC 25 ms 1792 KiB
2_max_6 AC 25 ms 1792 KiB
2_max_7 AC 25 ms 1792 KiB
2_max_8 AC 25 ms 1792 KiB
2_max_9 AC 25 ms 1792 KiB
3_nosub_0 AC 25 ms 1792 KiB
3_nosub_1 AC 25 ms 1792 KiB
3_nosub_2 AC 25 ms 1792 KiB
3_nosub_3 AC 25 ms 1792 KiB
3_nosub_4 AC 25 ms 1792 KiB
3_nosub_5 AC 25 ms 1792 KiB
3_nosub_6 AC 25 ms 1792 KiB
3_nosub_7 AC 25 ms 1792 KiB
3_nosub_8 AC 25 ms 1792 KiB
3_nosub_9 AC 25 ms 1792 KiB
sample_01 AC 1 ms 256 KiB
sample_02 AC 1 ms 256 KiB
sample_03 AC 1 ms 256 KiB