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

Обсуждение задачи 1105. Раскраска наблюдателей

I'm sure that my algorythm is correct. It's complexity is O
(n log n), because I use quicksort, and then 2 linear
procedures. Why do I get TimeLimitExceed? Is it possible
not to use sorting?
I have answers to all your questions :) Re: Is it possible to solve this problem without sorting? [3] // Задача 1105. Раскраска наблюдателей 15 ноя 2001 12:27
> I'm sure that my algorythm is correct. It's complexity is
O
> (n log n), because I use quicksort, and then 2 linear
> procedures. Why do I get TimeLimitExceed? Is it possible
> not to use sorting?

because complexity of quicksort in worst case is O(n^2)
use heapsort or mergesort and ur program 'll get accepted (
or at least not TimeLimitExceeded ) ;)
Just use Random-Quick-Sort it'll take a little time to run it.
you can use the quick sort in short algorithim
Still AC with O(N^2). ::)
But sorting i use.
do as this
#include <algorithm>
using namespace std;

int a[n];
sort(a,a+n);