poj3664 63ms sort水过

#include<cstdio>
#include<algorithm>
using namespace std;
//直接排序,无脑水过
const int N = 50005;
struct Node{
    int fir;
    int sec;
    int pos;
} cows[N];
bool cmp1(Node &a,Node &b)
{
    if(a.fir==b.fir) return a.sec>b.sec;
    return a.fir>b.fir;
}
bool cmp2(Node &a,Node &b)
{
    if(a.sec==b.sec) return a.fir>b.fir;
    return a.sec>b.sec;
}
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        for(int i = 0;i<n;++i){
            scanf("%d%d",&cows[i].fir,&cows[i].sec);
            cows[i].pos = i;
        }
        sort(cows,cows+n,cmp1);
        sort(cows,cows+k,cmp2);
        printf("%d\n",cows[0].pos+1);
    }
    return 0;
}
全部评论

相关推荐

程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
07-15 00:33
江苏大学 Java
代码飞升:哈哈哈哈评论区三个打广告的
简历中的项目经历要怎么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务