Codeforces 306B

 1 #include <cstdio>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdlib>
 5 #include <ctime>
 6 #include <cmath>
 7 #include <set>
 8 #include <map>
 9 using namespace std;
10 
11 const int maxm=int(2e5)+100;
12 
13 struct data
14 {
15     int x, y, num;
16     bool operator < (const data b) const
17     {
18         if (x!=b.x) return x<b.x;
19         return y>b.y;
20     }
21 };
22 
23 int n, m;
24 int ans;
25 data a[maxm];
26 bool vis[maxm];
27 
28 void init()
29 {
30     scanf("%d%d", &n, &m);
31     for (int i=1; i<=m; ++i)
32     {
33         scanf("%d%d", &a[i].x, &a[i].y);
34         a[i].y+=a[i].x-1;
35         a[i].num=i;
36     }
37     sort(a+1, a+1+m);
38 }
39 void solve()
40 {
41     ans=m;
42     for (int i=1, next; i<=m; i=next)
43     {
44         vis[a[i].num]=true;
45         ans--;
46         next=i;
47         int k=i+1;
48         while (k<=m && a[k].x<=a[i].y+1)
49         {
50             if (a[k].y>a[next].y) next=k;
51             ++k;
52         }
53         if (next==i) next=k; 
54     }
55     printf("%d\n", ans);
56     for (int i=1; i<=m; ++i)
57         if (!vis[i]) printf("%d ", i);
58 }
59 int main()
60 {
61     freopen("input.txt", "r", stdin);
62     freopen("output.txt", "w", stdout);
63     init();
64     solve();
65     return 0;
66 }
View Code

 

posted @ 2015-12-18 20:20  GerynOhenz  阅读(229)  评论(0编辑  收藏  举报