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:悲剧的我终于做到50了,继续努力,贴贴菜鸟代码

Posted by holybob at 2012-05-16 22:20:49 on Problem 3664
In Reply To:悲剧的我终于做到50了,继续努力,贴贴菜鸟代码 Posted by:bananas at 2012-05-16 19:47:27
> #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