Submission #3422688


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pii B[100005];

int main()
{
	int N, M;
	cin >> N >> M;
	REP(i, M)
	{
		cin >> B[i].first >> B[i].second;
	}
	sort(B, B + M, [](pii a, pii b) {return a.second < b.second; });
	int last = -1;
	int sum = 0;
	REP(i, M)
	{
		if (B[i].first <= last)continue;
		sum++;
		last = B[i].second - 1;
	}
	cout << sum << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Islands War
User coco18000
Language C++14 (GCC 5.4.1)
Score 400
Code Size 936 Byte
Status AC
Exec Time 81 ms
Memory 1152 KB

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 KB
0_small_1 AC 1 ms 256 KB
0_small_10 AC 1 ms 256 KB
0_small_2 AC 1 ms 256 KB
0_small_3 AC 1 ms 256 KB
0_small_4 AC 1 ms 256 KB
0_small_5 AC 1 ms 256 KB
0_small_6 AC 1 ms 256 KB
0_small_7 AC 1 ms 256 KB
0_small_8 AC 1 ms 256 KB
0_small_9 AC 1 ms 256 KB
1_rand_0 AC 4 ms 256 KB
1_rand_1 AC 29 ms 512 KB
1_rand_2 AC 68 ms 896 KB
1_rand_3 AC 68 ms 896 KB
1_rand_4 AC 11 ms 384 KB
1_rand_5 AC 58 ms 896 KB
1_rand_6 AC 32 ms 512 KB
1_rand_7 AC 53 ms 768 KB
1_rand_8 AC 22 ms 512 KB
1_rand_9 AC 62 ms 896 KB
2_max_0 AC 77 ms 1024 KB
2_max_1 AC 76 ms 1024 KB
2_max_2 AC 77 ms 1024 KB
2_max_3 AC 78 ms 1024 KB
2_max_4 AC 77 ms 1024 KB
2_max_5 AC 81 ms 1024 KB
2_max_6 AC 77 ms 1024 KB
2_max_7 AC 76 ms 1024 KB
2_max_8 AC 76 ms 1024 KB
2_max_9 AC 77 ms 1024 KB
3_nosub_0 AC 78 ms 1024 KB
3_nosub_1 AC 77 ms 1024 KB
3_nosub_2 AC 78 ms 1024 KB
3_nosub_3 AC 77 ms 1024 KB
3_nosub_4 AC 78 ms 1024 KB
3_nosub_5 AC 77 ms 1024 KB
3_nosub_6 AC 78 ms 1024 KB
3_nosub_7 AC 78 ms 1024 KB
3_nosub_8 AC 78 ms 1024 KB
3_nosub_9 AC 79 ms 1152 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB