码迷,mamicode.com
首页 > 其他好文 > 详细

E. Turn Off The TV Educational Codeforces Round 29

时间:2018-08-23 02:07:41      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:cto   min   off   注意   name   const   contest   str   efi   

http://codeforces.com/contest/863/problem/E

注意细节

 1 #include <cstdio>
 2 #include <cstdlib>
 3 #include <cmath>
 4 #include <cstring>
 5 #include <time.h>
 6 #include <string>
 7 #include <set>
 8 #include <map>
 9 #include <list>
10 #include <stack>
11 #include <queue>
12 #include <vector>
13 #include <bitset>
14 #include <ext/rope>
15 #include <algorithm>
16 #include <iostream>
17 using namespace std;
18 #define ll long long
19 #define minv 1e-6
20 #define inf 1e9
21 #define pi 3.1415926536
22 #define E  2.7182818284
23 const ll mod=1e9+7;//998244353
24 const int maxn=2e5+10;
25 
26 struct node
27 {
28     int x,y,z;
29 }f[maxn];
30 
31 bool vis[maxn]={0};
32 
33 int cmp(node a,node b)
34 {
35     if (a.x==b.x)
36         return a.y>b.y;
37     else
38         return a.x<b.x;
39 }
40 
41 int main()
42 {
43     int n,i,j,yy;
44     scanf("%d",&n);
45     for (i=1;i<=n;i++)
46         scanf("%d%d",&f[i].x,&f[i].y),f[i].z=i;
47     sort(f+1,f+n+1,cmp);
48     vis[f[1].z]=1;
49     j=1;
50     for (i=1;i<=n;)
51     {
52         yy=f[j].y+1;
53         i++;
54         j=i;
55         while (i<=n && f[i].x<=yy)
56         {
57             if (f[i].y>f[j].y)
58                 j=i;
59             i++;
60         }
61         if (f[j].y<=yy-1)
62             j=i;
63         else
64             i--;
65         vis[f[j].z]=1;
66     }
67     for (i=1;i<=n;i++)
68         if (!vis[i])
69         {
70             printf("%d",i);
71             return 0;
72         }
73     printf("-1");
74     return 0;
75 }
76 /*
77 3
78 
79 3687 7959
80 
81 4918 9822
82 
83 8049 11728
84 */

 

E. Turn Off The TV Educational Codeforces Round 29

标签:cto   min   off   注意   name   const   contest   str   efi   

原文地址:https://www.cnblogs.com/cmyg/p/9521050.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!