ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1306. Медиана последовательности

I'm a cheater! :)
Послано Alexander Kouprin 1 апр 2007 13:13
Bugaga! :)

I got AC!

So, it's my evil ideas:


I create array 1..236000 of cardinal - not int64!!
Longword type is good, too.

Read 1-235000 numbers and sort it.
Later I wrote this:

q:=235000;
z:=q;
repeat
for i:=1 to 1000 do
readln(a[z+i]);
sort(1,z+1000);
q:=q+1000;
until q>n;

Unkind solution. :P

And great output:
if (n mod 2)=0 then writeln(((a[n div 2]div 2)+(a[(n div 2)+1]div 2)+((a[(n div 2)]mod 2)+(a[(n div 2)+1]mod 2))div 2),'.',((a[(n div 2)+1]+a[(n div 2)])mod 2)*5  ) else writeln(a[(n div 2)+1],'.0');

So, what you say?
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 1 апр 2007 14:39
hm.. strange

Edited by author 01.04.2007 14:42
Re: I'm a cheater! :)
Послано Alexander Kouprin 1 апр 2007 20:06
What strange??
How you solve this problem?
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 1 апр 2007 20:20
is it really work or
it's 1 april joke?:)
I don't understand your out

I used another way (heap)
Re: I'm a cheater! :)
Послано Alexander Kouprin 1 апр 2007 20:32
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 1 апр 2007 20:42
No it's joke:)


ok...   It's not hard to understand

((a[(n div 2)]mod 2)+(a[(n div 2)+1]mod 2))div 2 =  0  or 1
((a[(n div 2)+1]+a[(n div 2)])mod 2)*5   =  5

heh..  evil cheater:)

Edited by author 01.04.2007 20:49

Edited by author 01.04.2007 20:55

Edited by author 01.04.2007 21:57
Re: I'm a cheater! :)
Послано Alexander Kouprin 1 апр 2007 20:45
If you can't beleive:

[AC code deleted by autor :)]

Edited by author 01.04.2007 20:57
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 1 апр 2007 20:51
ты нас не обманешь;)
see previous post
Re: I'm a cheater! :)
Послано Alexander Kouprin 1 апр 2007 21:03
Understand? :)
So, if you do this:

(a[(n div 2)+1]+a[n div 2]) div 2

you get numeric type overflow!
It's your A1 joke? :)

Use english! (Правда я сам его почти не знаю)
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 1 апр 2007 21:21
range checking off  by default

$FFFFFFFF + ($FFFFFFFF+1) = $FFFFFFFF
so  the value is also odd

What about cheaters progs?
see my a+b solution;)

http://acm.timus.ru/forum/thread.aspx?space=1&num=1000&id=13973&page=2&upd=633044683351698200
Re: I'm a cheater! :)
Послано Alexander Kouprin 1 апр 2007 21:34
Heh, ok. :)
I know this, $FFFFFFFF+1=$00000000.

But (3000000000+3000000000)div 2 is not 3000000000.
It's 852516352 (if you use cardinal, like me).

My shamanism (maybe shamanstvo? :)) worked correctly - answer is 3000000000.

So, what you say about this? ;)
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 1 апр 2007 22:10
I only now understand what you wrote:)
(output is long)
I'm sorry but it's simple calculations(no shamanism:)

((a[(n div 2)]mod 2)+(a[(n div 2)+1]mod 2))div 2 =
a[n shr 1]and a[n shr 1+1]and 1

may be better use int64 or real?

Edited by author 01.04.2007 22:12

Edited by author 01.04.2007 22:32
Re: I'm a cheater! :)
Послано Alexander Kouprin 1 апр 2007 22:52
Don't remember! We have only 1Mb of memory.
Short real types lose accuracy.
Int64 and big reals (like double and extended) need more memory and worked so slow.

I think using int64 we can't create minimal array - 125001 numbers, but I can't check it.
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 1 апр 2007 23:24
You can assign to real or int64 type before output

writeln(((a[n div 2]div 2)+(a[(n div 2)+1]div 2)+((a[(n div 2)]mod 2)+(a[(n div 2)+1]mod 2))div 2),'.',((a[(n div 2)+1]+a[(n div 2)])mod 2)*5 );

 equals to

writeln((int64(a[n div 2])+a[(n div 2)+1])/2:0:1);

Edited by author 01.04.2007 23:25
Re: I'm a cheater! :)
Послано Alexander Kouprin 2 апр 2007 00:44
> writeln((int64(a[n div 2])+a[(n div 2)+1])/2:0:1);

Is it correct?
What doing function int64();? Return value, which was be counted in int64 size?
Whether exists function real();?
Re: I'm a cheater! :)
Послано KIRILL(ArcSTU) 2 апр 2007 01:24
it's not function
it's type modification (приведение типа)
in this case expression will calc in int64 type

another easy way

var
  n1,n2:real;  //or int64
...
n1:=a[n div 2];
n2:=a[n div 2 +1];
writeln((n1+n2):0:1)
Re: I'm a cheater! :)
Послано Tolstobrov Anatoliy[Ivanovo SPU] 2 апр 2007 02:19

With LongInt
Write( A[N Div 2]/2 + A[N Div 2 +1]/2:1:1);
Re: I'm a cheater! :)
Послано Alexander Kouprin 2 апр 2007 03:12
To Anatoliy: It's worked too? Fun.
To KIRILL: Yes, you is right. It's easier.