FCan someone who had solved this task help me. I'm getting MLE on last test case.
My code => http://www.z-trening.com/new/www/html/submit.php?submit=7100051966&subm_code=1
Thanks in advance!
DWell I think your idea is good but it won't work cuz of it uses to much memory...
gand btw Dgleich, I think you have luck with this task..worst case of your solution is O( n^2 ) which is too much for n = 100 000, so tests are bad.. :)
Fgates, can you please look in my code and tell me what optimization can I use to solve this task? Thanks
g@FilipKeri: your approach is slow too..maybe you can get ac because tests are bad.
my approach is to sweep through posters and maintain current posters in set.
for every start of poster O( lg N ) complexity to insert poster and for every end of poster O( lg N ) complexity to erase it.
since every poster is inserted and erased exactly once complexity is O( N lg N )
fsomenone please take a look of my code in http://www.z-trening.com/submit.php?submit=7100065154&subm_code=1
I don't know where my fault is.... Please help!
Mhmm u first sort all the lenghts and then go throught posters?i have a problem with implementing this with set cause i cant get the biggest number in a set other than in linear time:S|
and i dont feel like making my own BST:D
Mso s.begin points always to the largest element???
Mok s.begin() points to the smallest and then for s.begin to s.end u get the elements sorted in the ascending order.
DMatteo, that's not going to work... Because S.end() isn't really an element, so you need to get *(--S.end()); :)
Mno u will also get the biggest element that way
even if u increase the iterator like this
it=s.end()
it++
*it will still point to the biggest element
mOn my computer, it works, because I tried.
DI just tryed and it's not working try:
set < int > S;
S.insert( 5 );
S.insert( 4 );
S.insert( 2 );
printf("%d\n",*(--S.end())); //return 5
printf("%d\n",*S.end()); //it returned 3 for me
Mwhat compiler are u using??
i have DEV-C++,dont know whats his compiler but it works just fine at my comp:D