Submission #2880438


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector< pair<int,int> > V;
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    V.emplace_back(b,a);
  }
  sort(V.begin(), V.end());
  int ans = 0, l = -1;
  for(int i = 0; i < M; ++i){
    if(V[i].second >= l){
      ++ans;
      l = V[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Islands War
User TAB
Language C++14 (GCC 5.4.1)
Score 400
Code Size 457 Byte
Status
Exec Time 65 ms
Memory 1400 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03
All 400 / 400 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 1 ms 256 KB
0_small_1 1 ms 256 KB
0_small_10 1 ms 256 KB
0_small_2 1 ms 256 KB
0_small_3 1 ms 256 KB
0_small_4 1 ms 256 KB
0_small_5 1 ms 256 KB
0_small_6 1 ms 256 KB
0_small_7 1 ms 256 KB
0_small_8 1 ms 256 KB
0_small_9 1 ms 256 KB
1_rand_0 4 ms 384 KB
1_rand_1 25 ms 892 KB
1_rand_2 57 ms 1400 KB
1_rand_3 58 ms 1400 KB
1_rand_4 10 ms 512 KB
1_rand_5 49 ms 1400 KB
1_rand_6 27 ms 892 KB
1_rand_7 44 ms 1400 KB
1_rand_8 19 ms 640 KB
1_rand_9 53 ms 1400 KB
2_max_0 64 ms 1400 KB
2_max_1 64 ms 1400 KB
2_max_2 64 ms 1400 KB
2_max_3 64 ms 1400 KB
2_max_4 64 ms 1400 KB
2_max_5 64 ms 1400 KB
2_max_6 64 ms 1400 KB
2_max_7 64 ms 1400 KB
2_max_8 65 ms 1400 KB
2_max_9 64 ms 1400 KB
3_nosub_0 65 ms 1400 KB
3_nosub_1 65 ms 1400 KB
3_nosub_2 65 ms 1400 KB
3_nosub_3 65 ms 1400 KB
3_nosub_4 65 ms 1400 KB
3_nosub_5 65 ms 1400 KB
3_nosub_6 65 ms 1400 KB
3_nosub_7 65 ms 1400 KB
3_nosub_8 65 ms 1400 KB
3_nosub_9 65 ms 1400 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB