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

悲剧的我终于做到50了,继续努力,贴贴菜鸟代码

Posted by bananas at 2012-05-16 19:47:27 on Problem 3664
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
struct Person
{
       int a,b,f;
} p[50005];
bool cmp(const Person&A,const Person&B)
{
     if(A.a>B.a||A.a==B.a&&A.b>B.b)
       return true;
     return false;
 }
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    memset(p,0,sizeof(p));
    for(int i=0; i<n; i++)
    {
            scanf("%d%d",&p[i].a,&p[i].b);
            p[i].f=i+1;
    }
    sort(p,p+n,cmp);
    int mx=0;
    for(int i=1; i<k; i++)
       if(p[mx].b<p[i].b)
            mx=i;
    printf("%d\n",p[mx].f);
    system("pause");
    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