Submission #29419


Source Code Expand

#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

#define REPN(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) REPN(i, 0, n)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

typedef pair<int, int> PII;

bool comp(const PII& lhs, const PII& rhs) {
  return lhs.second - lhs.first > rhs.second - rhs.first;
}

int main() {

  int N, M;
  scanf("%d%d", &N, &M);

  vector<PII> v;
  REP(i, M) {
    int a, b;
    scanf("%d%d", &a, &b);
    v.push_back(PII(a, b));
  }

  int res = 0;
  for(int p = 1; p <= N; ) {
    int max_l = 0, idx = 0;
    REP(i, M) {
      if(v[i].first <= p && p <= v[i].second) {
        if(v[i].second > max_l) {
          max_l = v[i].second;
          idx = i;
        }
      }
    }
    if(max_l == 0) {
      printf("Impossible\n");
      return 0;
    }
    p = max_l + 1;
    res++;
  }

  printf("%d\n", res);

  return 0;
}

Submission Info

Submission Time
Task D - 権力
User miya
Language C++ (G++ 4.6.4)
Score 100
Code Size 1047 Byte
Status AC
Exec Time 22 ms
Memory 820 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:26:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 53
Set Name Test Cases
All 00_sample_1, 00_sample_2, 00_teuchi_1, 00_teuchi_2, 00_teuchi_3, 00_teuchi_4, 10_max1_06, 10_max1_07, 10_max1_08, 10_max1_09, 10_max1_10, 10_max1_11, 10_max1_12, 10_max2_13, 10_max2_14, 10_max2_15, 10_max2_16, 10_max2_17, 10_max2_18, 10_max2_19, 10_max2_20, 10_max2_21, 10_max2_22, 10_min_00, 10_min_01, 10_min_02, 10_min_03, 10_min_04, 10_min_05, 10_rand_27, 10_rand_28, 10_rand_29, 10_rand_30, 10_rand_31, 10_rand_32, 10_rand_33, 10_rand_34, 10_rand_35, 10_rand_36, 10_rand_37, 10_rand_38, 10_rand_39, 10_rand_40, 10_rand_41, 10_rand_42, 10_rand_43, 10_rand_44, 10_rand_45, 10_rand_46, 10_unif_23, 10_unif_24, 10_unif_25, 10_unif_26
Case Name Status Exec Time Memory
00_sample_1 AC 21 ms 728 KiB
00_sample_2 AC 21 ms 792 KiB
00_teuchi_1 AC 21 ms 788 KiB
00_teuchi_2 AC 22 ms 780 KiB
00_teuchi_3 AC 21 ms 812 KiB
00_teuchi_4 AC 21 ms 820 KiB
10_max1_06 AC 21 ms 784 KiB
10_max1_07 AC 20 ms 788 KiB
10_max1_08 AC 21 ms 788 KiB
10_max1_09 AC 21 ms 788 KiB
10_max1_10 AC 21 ms 792 KiB
10_max1_11 AC 21 ms 792 KiB
10_max1_12 AC 21 ms 760 KiB
10_max2_13 AC 21 ms 792 KiB
10_max2_14 AC 21 ms 788 KiB
10_max2_15 AC 21 ms 800 KiB
10_max2_16 AC 21 ms 788 KiB
10_max2_17 AC 21 ms 788 KiB
10_max2_18 AC 21 ms 768 KiB
10_max2_19 AC 20 ms 788 KiB
10_max2_20 AC 21 ms 820 KiB
10_max2_21 AC 21 ms 792 KiB
10_max2_22 AC 21 ms 736 KiB
10_min_00 AC 21 ms 796 KiB
10_min_01 AC 21 ms 796 KiB
10_min_02 AC 21 ms 792 KiB
10_min_03 AC 21 ms 800 KiB
10_min_04 AC 21 ms 792 KiB
10_min_05 AC 21 ms 792 KiB
10_rand_27 AC 21 ms 784 KiB
10_rand_28 AC 21 ms 792 KiB
10_rand_29 AC 21 ms 792 KiB
10_rand_30 AC 21 ms 736 KiB
10_rand_31 AC 20 ms 792 KiB
10_rand_32 AC 21 ms 796 KiB
10_rand_33 AC 21 ms 792 KiB
10_rand_34 AC 21 ms 736 KiB
10_rand_35 AC 20 ms 780 KiB
10_rand_36 AC 21 ms 812 KiB
10_rand_37 AC 21 ms 796 KiB
10_rand_38 AC 21 ms 788 KiB
10_rand_39 AC 21 ms 788 KiB
10_rand_40 AC 21 ms 800 KiB
10_rand_41 AC 21 ms 796 KiB
10_rand_42 AC 21 ms 792 KiB
10_rand_43 AC 21 ms 792 KiB
10_rand_44 AC 21 ms 788 KiB
10_rand_45 AC 21 ms 784 KiB
10_rand_46 AC 20 ms 788 KiB
10_unif_23 AC 21 ms 788 KiB
10_unif_24 AC 21 ms 792 KiB
10_unif_25 AC 21 ms 756 KiB
10_unif_26 AC 21 ms 816 KiB