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 1424. Minibus

Simple problem or weak tests?
Posted by Fyodor Menshikov 15 May 2007 02:19
My solution should use 2 * M * K indexations of linear array in the worst case (100 000 000 for max M and K) but works about 0.5s, twice less than time limit, and it is Java!

Does it mean that so simple algorithm is enough or that tests are weak?

Edited by author 15.05.2007 02:27
Re: Simple problem or weak tests?
Posted by Alexander Kouprin 15 May 2007 03:57
I used greedy algo, pascal, 0.265sec works, O(2*M*K) too.
Re: Simple problem or weak tests?
Posted by svr 15 May 2007 10:47
For such strong authors request of failed solver!
Give us short clarification of this great optimization
problem!
What is more simple prototipe of it?
What class of the problem? Graphs?DP? May be....
O(M*K) solution is ok (+)
Posted by Dmitry 'Diman_YES' Kovalioff 15 May 2007 11:54
Timus Online Judge server is fast enough to perform more than 100000000 operations per second.

The problem is based on the Activity Selection problem.
Re: Simple problem or weak tests?
Posted by Fyodor Menshikov 15 May 2007 12:01
svr wrote 15 May 2007 10:47
What is more simple prototipe of it?

I don't know.
svr wrote 15 May 2007 10:47
What class of the problem? Graphs?DP? May be....

I'd said simulation. And I think Alexander Kouprin's definition "greedy" is right.

The problem gets simpler if you change its model. You can allow driver to debus any boarded passenger at any stop < F[i] refunding the passenger all her money P. The driver in this case would get the same amound of money as if he would not board that debussed half-way passengers at all.

Edited by author 15.05.2007 14:09
About server speed
Posted by Fyodor Menshikov 15 May 2007 12:08
Dmitry 'Diman_YES' Kovalioff wrote 15 May 2007 11:54
Timus Online Judge server is fast enough to perform more than 100000000 operations per second.

The truth of this statement depends on operation kind. Recently I solved problem in which 50 000 000 operations * and % on 64-bit integers worked 2s.

Dmitry, do you know more precise numbers, how many operations of each kind the server can execute per second? For example linear array indexations - 180 bln, long multiplication - 100 bln and so on...
Re: Simple problem or weak tests?
Posted by Alexander Kouprin 15 May 2007 12:29
I'd said it's sorting problem. :)
You have segments of way: first point and last.
Your task is how to combinate maximum of segment in K lines.
This lines can be severed inside of itself and have big holes.
Re: Simple problem or weak tests?
Posted by Fyodor Menshikov 15 May 2007 14:16
Alexander Kouprin wrote 15 May 2007 12:29
I'd said it's sorting problem. :)

I used sorting too, but I think the main problem is to devise what to do after sorting.
I think one can find the performance rate himself (+)
Posted by Dmitry 'Diman_YES' Kovalioff 15 May 2007 16:53
Just write a kind of performance mark program, submit it and you will get exactly what you want.

Then you may post the results here and everyone will appreciate your work.
Re: O(M*K) solution is ok (+)
Posted by svr 16 May 2007 22:37
Is Activity Selection problem standard internet term?
Re: Simple problem or weak tests?
Posted by SPIRiT 27 Jun 2007 14:00
I think it's a lecture hall assignment problem. One thing is that number of lecture halls here is limited by M...
Re: Simple problem or weak tests?
Posted by svr 27 Jun 2007 14:08
Thank for "lecture hall assignment" brand!
Re: Simple problem or weak tests?
Posted by SPIRiT 4 Jul 2007 17:57
I tried to solve it running Greedy-Activity-Selector M times. But WA at test 4. What is wrong with such approach?
Re: Simple problem or weak tests?
Posted by svr 29 Sep 2007 14:34
Gready _Activity_Selector of course.
But with auxiliary subproblem:
Let we have a set S={[ai,bi]} intervals chosen to some
moment and according with greedy should include in S
new segment [c,d]. Can we do it without excess of M.
For, we must solve the problem of maximal overlapping
value. I used augmented red-black tree
as in Cormen but have very bad time 0.843 AC.
Intuition says that good times taken due better
ways of solving auxiliary problem.

Edited by author 29.09.2007 14:41
Re: Simple problem or weak tests?
Posted by SPIRiT 3 Oct 2007 21:35
Thanks, I realised that. I simply store now all stations beginnings in an array (maximum K). I initialise it with M value for each element. Now, for each request I go from start to end and check if all elements are non-zero (not including the end). If that requirement is met, I add the request to the result and decrement all checked elements
Re: Simple problem or weak tests?
Posted by SPIRiT 9 Oct 2007 18:55
By the way. Should we sort just time ending of the activity? In that case I get WA#4, If I sort beginnings in decreasing order in case of end equals, I get TLE #4
Re: Simple problem or weak tests?
Posted by marius dumitran 29 Oct 2007 12:50
my algo is
O(N + K *log(M))  -> AC in 0.1
Re: Simple problem or weak tests?
Posted by Denis Koshman 20 Aug 2008 12:02
Mine too :)
Re: Simple problem or weak tests?
Posted by hoan 29 Dec 2010 20:35
i use segment tree and got AC in 0.109.
what's the best algo?
order of my algo is O((n+m)logn + klogk).
GOOD LUCK!!!