ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1306. Sequence Median

Почему WA7?
Posted by JamesBond_007 16 Mar 2016 11:54
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <stdio.h>
using namespace std;
unsigned int a[150002],k,kk,n,q,i;
int main()
{
cin >> n;
if(n > 150000){
k = n - 150000;
n = 150000;
}
for(i = 1;i < n+1; i ++){
cin >> a[i];
}
sort(a,a+n+1);
for(i = 1; i <= k; i ++){
cin >> q;
if(a[n] > q) a[i] = q;
}
if(k > 0)
sort(a,a+n+1);
if((n + k) % 2 == 1){
cout << a[ n / 2 + 1 - k]<< endl;
}else {
kk = a[n / 2 - k] % 2 + a[n / 2 + 1 - k] % 2;
cout << (1ll * a[n / 2 - k] + a[n / 2 + 1 - k]) / 2;
if(kk == 1)cout << ".5";
}
}
Re: Почему WA7?
Posted by ToadMonster 16 Mar 2016 14:40
Sorry, was wrong.

Edited by author 17.03.2016 14:29