ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1100. Final Standings

WA on test case 1......please please help
Posted by sarvin 26 Dec 2014 17:06
following is my solution in C.I have used qsort() function of library stdlib.I have checked it on all test cases but still I am not able to figure out which test case is getting wrong..please help...i have really spend a lot of time on this.
#include<stdio.h>
#include<stdlib.h>
struct TwoInt
{
    long int a;
    int b;
};
typedef struct TwoInt Int;
Int arr[200000];
int cmpfnc(const void* a,const void* b)
{
 const int p=((const Int*)a)->b;
 const int q=((const Int*)b)->b;
 if(p>q)
  return q-p;
 else
  {
     if(p<q)
  return q-p;

  }
  return 0;

}
int main()
{
long int n;
scanf("%ld",&n);
long int i=0;
for(i=0;i<n;i++)
scanf("%ld %d",&(arr[i].a),&(arr[i].b));

qsort(arr,n,sizeof(Int),cmpfnc);

for(i=0;i<n;i++)
printf("%ld %d\n",arr[i].a,arr[i].b);
return 0;
}
Re: WA on test case 1......please please help
Posted by Indroneal 8 Aug 2016 20:21
me too . :(
Re: WA on test case 1......please please help
Posted by ToadMonster 9 Aug 2016 17:45
Is C qsort() stable?

P.S. Oops. Answer to necro-post...

Edited by author 09.08.2016 17:46