E. Turn Off The TV Educational Codeforces Round 29

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

注意细节

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define E 2.7182818284
const ll mod=1e9+;//
const int maxn=2e5+; struct node
{
int x,y,z;
}f[maxn]; bool vis[maxn]={}; int cmp(node a,node b)
{
if (a.x==b.x)
return a.y>b.y;
else
return a.x<b.x;
} int main()
{
int n,i,j,yy;
scanf("%d",&n);
for (i=;i<=n;i++)
scanf("%d%d",&f[i].x,&f[i].y),f[i].z=i;
sort(f+,f+n+,cmp);
vis[f[].z]=;
j=;
for (i=;i<=n;)
{
yy=f[j].y+;
i++;
j=i;
while (i<=n && f[i].x<=yy)
{
if (f[i].y>f[j].y)
j=i;
i++;
}
if (f[j].y<=yy-)
j=i;
else
i--;
vis[f[j].z]=;
}
for (i=;i<=n;i++)
if (!vis[i])
{
printf("%d",i);
return ;
}
printf("-1");
return ;
}
/*
3 3687 7959 4918 9822 8049 11728
*/
上一篇:mac 环境搭建


下一篇:oc-06-无参方法的调用