Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:显然是可以过的啊

Posted by chubuxiao2015 at 2016-04-07 10:57:02 on Problem 3664
In Reply To:注意了用sort不一定能过 Posted by:1314199210 at 2013-07-31 16:44:06
> 如题,代码:
#include<stdio.h>
#include<algorithm>
using namespace std;
int i,j,k,n;
struct ff {int first,second,node;}a[50005];
bool cmp1(ff x,ff y)
{
     if(x.first==y.first) return x.second>y.second;
     return x.first>y.first;
}
bool cmp2(ff x,ff y)
{
     if(x.second==y.second) return x.first>y.first;
     return x.second>y.second;
}
int main()
{
    scanf("%d %d",&n,&k);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].first,&a[i].second);
        a[i].node=i;
    }
    sort(a+1,a+n+1,cmp1);
    sort(a+1,a+k+1,cmp2);
    printf("%d\n",a[1].node);
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator