poj3664

水题,进行两次排序即可

 

 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int maxn = 50005;

struct Cow
{
	int a, b, num;
}cow[maxn];

bool cmp1(const Cow &a, const Cow &b)
{
	return a.a > b.a;
}

bool cmp2(const Cow &a, const Cow &b)
{
	return a.b > b.b;
}

int main()
{
	//freopen("D:\\t.txt", "r", stdin);
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &cow[i].a, &cow[i].b);
		cow[i].num = i;
	}
	sort(cow, cow + n, cmp1);
	sort(cow, cow + k, cmp2);
	printf("%d\n", cow[0].num + 1);
	return 0;
}
posted @ 2011-02-01 13:52  金海峰  阅读(407)  评论(0编辑  收藏  举报