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 1306. Sequence Median

Why WA?
Posted by night beast 20 Sep 2005 10:38
#include <vector>
#include <algorithm>
#include <iostream>

typedef unsigned long number;

int main ()
{
    int size;
    std::vector<number> data;
    data.reserve (250000);

    std::cin >> size;
    for ( int i=0; i<size; ++i ) {
        data.push_back (0);
        std::cin >> data[i];
    }
    std::sort ( data.begin(), data.end() );

    if ( size%2 ) {
        std::cout << data[(size+1)/2-1];
    } else {
        number l = data[size/2-1];
        number r = data[size/2];
        switch ( (l%2) + (r%2) ) {
        case 0: std::cout << l/2+r/2; break;
        case 1: std::cout << l/2+r/2 << ".5"; break;
        case 2: std::cout << l/2+r/2+1; break;
        }
    }

    return 0;
}
Re: Why WA?
Posted by night beast 20 Sep 2005 15:16
damn! they used different output format