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

Why WA!!!!!哪位高手帮我找找错啊

Posted by yuech at 2009-07-15 20:09:01 on Problem 3664
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct st
{
  long a;
  long b;
  };
int cmp(const st &p,const st &q)
{
     return p.a>q.a;
   }
int main()
{
    int n,k,i,h;
    st c[50005];
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
      scanf("%ld %ld",&c[i].a,&c[i].b);
    sort(c,c+n,cmp);
      h=0;
  
    for(i=1;i<k;i++)
       if(c[i].b>c[h].b)
          h=i;
      printf("%ld\n",c[h].b);
         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