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 1207. Median on the Plane

WA on Test#7 Please HELP!!!!
Posted by MultiThread 22 Sep 2006 13:48

The code is below:
WHY WA :-(

#include <stdio.h>

struct point
{
    long x;
    long y;
    int id;
};


void Sort (point points[], int n)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - i - 1; j++)
        {
            double r1 = points[j+1].y * points[j].x;
            double r2 = points[j].y * points[j+1].x;
            if (r1 < r2)
            {
                point t = points[j];
                points[j] = points[j+1];
                points[j+1] = t;
            }
        }
    }
}

void main()
{
    int N = 0;
    scanf ("%d", &N);

    const int MAX = 10000;
    point points[MAX] = {0};

    for (int i = 0; i < N; i++)
    {
        scanf ("%ld%ld", &points[i].x, &points[i].y);
        points[i].id = i + 1;
    }

    Sort (points, N);

    printf ("%d %d", points[0].id, points[N/2].id);

}