CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • May Cook-Off
    • May Long 2012
    • April Cook-Off
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » April 2010 Contest » Adding Fractions

Adding Fractions

Problem code: ADDFRAC

  • All Submissions

All submissions for this problem are available.

You have discovered a new way to add fractions ! Now, the result of adding fractions a/b and c/d is (a + c)/(b + d). Similarly the result of adding 3 fractions a/b, c/d, e/f is (a + c + e)/(b + d + f), and so on. You are given a list of N fractions a_1/b_1, a_2/b_2,...,a_N/b_N. You wonder what for each fraction i is the maximum fraction that you can obtain by adding together some continuous fractions in the list (possibly 1) starting at i ?

For example, let N = 4 and the fractions be 1/1, 4/3, 10/1 and 5/4. The maximum fraction you can obtain by starting at index 1 is 3/1 (1/1 + 4/3 + 10/1). Similarly, the maximum fraction you can obtain by starting at index 2 is 7/2 (4/3 + 10/1). By starting at index 3, the maximum sum you can obtain is 10/1 itself, and by starting at index 4, you can obtain sum 5/4.

Input :

The first line contains T the number of test cases. T test cases follow. The first line of each test case contains N. Each of the next N lines contains a fraction given in the form "a_i/b_i". A blank line seperates two test cases.

Output :

For each test case, output N lines. The ith line contains the maximum fraction you can obtain by adding continuous fractions in the list starting at index i. The numerator and denominator of any fraction you output should have gcd 1. Output a blank line after each test case.

Sample Input :

2
4
1/1
4/3
10/1
5/4

5
1/3
3/1
2/5
5/6
6/5

Sample Output :

3/1
7/2
10/1
5/4

1/1
3/1
13/16
1/1
6/5

Constraints :

1 <= T <= 5
1 <= n <= 100000
1 <= a_k,b_k <= 100000


Date: 2010-03-20
Time limit: 2s
Source limit: 50000
Languages: C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK JS


  • Submit

Comments

  • Login or Register to post a comment.

Sites like codechef are not

utkarsh_lath @ 2 Apr 2010 02:37 PM

Sites like codechef are not expected to make april Fool of programmers. This is ridiculous.

ok utkarsh calm down....!!!

mayuresh.1590 @ 2 Apr 2010 07:53 PM

ok utkarsh calm down....!!!

If I were a superman I would

vikeshkhanna @ 2 Apr 2010 09:56 PM

If I were a superman I would have sued CodeChef (or probably knocked you guys down since I am a superman) for your extremely stringent time limits!

and strangled you to death

vikeshkhanna @ 2 Apr 2010 09:58 PM

and strangled you to death for not giving delete option for comments.

Comment edited by Admin.

vermapratyush @ 2 Apr 2010 11:00 PM

Comment edited by Admin.

Now ,i'm frustated .Unable to

gurpreet_09 @ 3 Apr 2010 01:15 AM
Now ,i'm frustated .Unable to find where is the mistake.It's a simple linear algorithm according to me . still getting WA :(:(:(

Comment edited by Admin.

madmaxwell @ 3 Apr 2010 01:45 AM

Comment edited by Admin.

Comment edited by Admin.

codeyou @ 3 Apr 2010 02:02 AM

Comment edited by Admin.

This is a general comment: If

ma13 @ 3 Apr 2010 04:38 AM

This is a general comment:

If more test cases can be posted, these events can serve as a learning tool too where people can think about what happened in particular cases. In the present way, it is only for the ones who can already do it. It does not help the cause of people who are starters and are trying to learn the concepts and techniques.

I hope the administrators pay some attention. :) cheers.

+@jedi

codegambler @ 3 Apr 2010 09:42 AM

+@jedi

Comment edited by Admin.

sankikhopadi @ 3 Apr 2010 09:46 AM

Comment edited by Admin.

Comment edited by Admin.

codegambler @ 3 Apr 2010 09:51 AM

Comment edited by Admin.

Comment edited by Admin.

codegambler @ 3 Apr 2010 09:59 AM

Comment edited by Admin.

@ Pankaj, I'm also stuck at

gurpreet_09 @ 3 Apr 2010 10:11 AM
@ Pankaj, I'm also stuck at the same point. My logic is also similar to yours, (me too getting WA)..... Some corner cases must be missing using this algorithm :( .

in every competition we could

codegambler @ 3 Apr 2010 10:20 AM

in every competition we could able to think the solution but due to little mistake we couldn't able to pass the judge.

Comment edited by Admin.

dabbcomputers @ 3 Apr 2010 10:26 AM

Comment edited by Admin.

Comment edited by Admin.

codegambler @ 3 Apr 2010 10:36 AM

Comment edited by Admin.

well.. my logic also is

progfool @ 3 Apr 2010 11:07 AM

well.. my logic also is almost simliar..... dont know.. these wrong answers and TLE's has left so less hairs on mah head :P

Nothing is wrong with the

triplem @ 3 Apr 2010 12:08 PM

Nothing is wrong with the judge. If you are getting WA that means you have the wrong answer.

@ jedi knight - sample test

triplem @ 3 Apr 2010 12:26 PM

@ jedi knight - sample test cases aren't meant to give you any ideas whatsoever as to the answer; they are solely there to clarify the problem statement.

It is very easy to make up more test cases yourself and find out the correct result by trying all possibilities. You would learn far more doing that than having more provided for you. Indeed, that's exactly what I did to try to figure out how to solve the problem (and almost every single other one I've solved).

If you want to practice, do practice problems instead.

Comment edited by Admin.

progfool @ 3 Apr 2010 01:41 PM

Comment edited by Admin.

Comment edited by Admin.

vermapratyush @ 3 Apr 2010 03:50 PM

Comment edited by Admin.

You understand discussing

triplem @ 3 Apr 2010 04:34 PM

You understand discussing algorithms like this will get your disqualified, right?

well am not discussing algos

vermapratyush @ 3 Apr 2010 04:38 PM

well am not discussing algos here.. but tricks (to reduce runtime).. i dont think that will get me disqualified.. or will it.. ????

Umm.. I dont think I anywhere

progfool @ 3 Apr 2010 05:06 PM

Umm.. I dont think I anywhere said that the algo stated above was correct or not... I know that this is a competition and I will refrain from discussing algo..

I just stated something which I think is a stupid issue for which codes are not accepted....

Codechef rocks :D

Manoharprabhu @ 3 Apr 2010 07:08 PM

Codechef rocks :D

@ Vivek Agarwal I think you

abhithekid @ 3 Apr 2010 08:34 PM

@ Vivek Agarwal

I think you ought to leave people to look at constraints and figure out whatever you had suggested.

Oops, sorry for posting in

abhithekid @ 3 Apr 2010 08:36 PM

Oops, sorry for posting in bold. Didn't realize :)

Comment edited by Admin.

moneymachine @ 3 Apr 2010 08:50 PM

Comment edited by Admin.

Had Fun To solve it. Thanks

white_king @ 3 Apr 2010 09:01 PM
Had Fun To solve it. Thanks to the setter :)

hmmm, I did every thing

mohan krishna @ 3 Apr 2010 09:25 PM

hmmm,

I did every thing which i can to reduce my time complexity but still it is the same T L E...

can anyone help me out on this plz...?

@ all i got run time error

muke @ 3 Apr 2010 09:36 PM

@ all

i got run time error and error code is "SIGSEGV"

can anybody tell me what it mean

Admin please reply

Guys ... I have checked this

kapil_sni @ 3 Apr 2010 09:41 PM

Guys ... I have checked this program on my machinr exactly the way CODE chef checks it by using files..

i am getting right solution on my machinr still i m gettin RUNTIME ERROR on codechef..

any help will be appriciated ....

Comment edited by Admin.

dabbcomputers @ 3 Apr 2010 09:43 PM

Comment edited by Admin.

@KAPIL either u r not using

dabbcomputers @ 3 Apr 2010 09:48 PM

@KAPIL

either u r not using RETURN statement or using huge memory.....

@udayrocks2k8 plz tell me

muke @ 3 Apr 2010 10:02 PM

@udayrocks2k8

plz tell me what is meaning of SIGSEGV.

@ admin.. plz disqualify

mcsharma1990 @ 3 Apr 2010 10:24 PM

@ admin..

plz disqualify those people who are discussing algo here.

Edited by admin

mohan krishna @ 3 Apr 2010 10:59 PM

Edited by admin

can anybody tell me what can

idontknowisitim @ 3 Apr 2010 11:02 PM

can anybody tell me what can be reason behind getting run time error as my program is running without any error on my PC please reply

IT COULD BE BECAUSE U R USINF

mohan krishna @ 3 Apr 2010 11:06 PM

IT COULD BE BECAUSE U R USINF ARRAYS OF LESS SIZE THAN WAT IT IS REQUIRED...

is there any space between

idontknowisitim @ 3 Apr 2010 11:14 PM

is there any space between input

is input is like

1 / 1

or

1/1

It does not matter whether

triplem @ 4 Apr 2010 02:27 AM

It does not matter whether you are discussing the wrong algorithm or the right algorithm. Discussing any strategies, hints or tips will get you disqualified. That includes replying about other test cases.

Please cut it out, all of you.

@Stephen Merriman I agree

ma13 @ 4 Apr 2010 03:16 AM

@Stephen Merriman I agree that one should practice in the Practice section. That is why i said this is a comment in general. The practice questions don't have test cases provided either! But I guess there are better websites to help learn things than CodeChef.

Comment edited by Admin.

loopback @ 4 Apr 2010 04:23 AM

Comment edited by Admin.

@Szymon Did you not read what

triplem @ 4 Apr 2010 05:02 AM

@Szymon Did you not read what I just wrote? Discussing test cases will disqualify you from the contest.

Thanks for tipping me off

Flopsy @ 4 Apr 2010 10:50 AM

Thanks for tipping me off about the linear algorithm, everyone...

does atoi(char* C)  work on

mayank.punetha @ 4 Apr 2010 02:41 PM

does atoi(char* C)  work on ur compiler?? Because on compiling my code in DEVC++ I get no-error while ur bot gives a compile error!!

finally .... :)

f03nix @ 4 Apr 2010 03:18 PM

finally .... :)

uuuufffffffffffffffffffff!!!!

gurpreet_09 @ 4 Apr 2010 06:51 PM

uuuufffffffffffffffffffff!!!!!!!!!!!!!!!! done it..........

I must check 4 the corner cases otherwise :(:(:(:(:(

@jedi could you name  a few

vermapratyush @ 4 Apr 2010 07:16 PM

@jedi could you name  a few from where i can learn new things... instead of getting fustrated by seeing TLEs in CodeChef...

@Pratyush Verma   Don't get

gautamverma @ 4 Apr 2010 07:26 PM

@Pratyush Verma

 

Don't get furstarte by TLE's. If you want to learn then start working at topcoder & spoj. Frequatly post & read Topcoder Forums Really they are amazing. You will learn a lot.

I can't find what's causing a

chandniverma @ 4 Apr 2010 07:48 PM

I can't find what's causing a runtime error to pop up? can we have some test cases?

is there is need to scan a

dabbcomputers @ 4 Apr 2010 11:03 PM

is there is need to scan a blank line after each input test case.

i saw some available solution on previous problem having same condition but user not scan the blank line. as mention in statement.

please clarify the my problem. is this can cause wrong answer.

please help.

Comment edited by Admin.

dabbcomputers @ 5 Apr 2010 12:00 AM

Comment edited by Admin.

If anyone answers that they

triplem @ 5 Apr 2010 02:31 AM

If anyone answers that they will get disqualified, so please don't ask :)

hi friends... i am getting

cooltodinesh @ 5 Apr 2010 04:24 AM

hi friends...

i am getting really scared about TLE "time limit exceed " matter.

i wasted all 5 hours optimizing code after getting soluiton..stil it gives TLE.

i minimized code to 75 lines........

plz let me what wud help me.

any reference to read please.

this is my first problem, i solved correct.

You won't get any real hints

triplem @ 5 Apr 2010 04:49 AM

You won't get any real hints towards your actual problem during the contest.

If you haven't read the FAQ (which you can't have, or you wouldn't have posted that comment), you should read it.

Are the time limits the same

Sumudu @ 5 Apr 2010 09:34 AM

Are the time limits the same for all the languages?  I'm pretty confident I have the right idea for my solution, but my local tests make it seem impossible to finish 5 cases with N = 100000 within 2 seconds, using Haskell (I/O seems to be my bottleneck here).  I was also a little worried to see the times on the scoreboard in the neighbourhood of 1 second using C++, in my experience Haskell will be a few times slower.

Any suggestions?  Confirmation that the given time limit is possible with a slower language is all that I'm looking for.

Some languages have more time

triplem @ 5 Apr 2010 10:13 AM

Some languages have more time allocated, but I'm not aware of Haskell being one of them. It is rare to find Haskell programmers here and the time limit for this problem is pretty strict - it may simply be impossible to solve this problem with Haskell.

Thanks for the reply.  I'm

Sumudu @ 5 Apr 2010 10:37 AM

Thanks for the reply.  I'm still learning Haskell so I might be doing the I/O in an inefficient way -- experimenting on the "Enormous Input" practice problem helped me discover how easy it is to dramatically slow down one's program by neglecting to make something strict.  Anyway I coded my solution in C++ and passed.

The Output specification

Flopsy @ 5 Apr 2010 02:22 PM

The Output specification says: "output a blank line after each test case." Why doesn't the Sample Output contain a blank line after the second test case? This seems to violate the specification.

It should. But it makes no

triplem @ 5 Apr 2010 02:45 PM

It should. But it makes no difference whatsoever anyway; the judge considers all whitespace as equal, and trims extra whitespace from the front/end of your output.

I'd like to request everyone

admin @ 5 Apr 2010 04:45 PM
I'd like to request everyone to not ask for hints or post code / hints for the currently running contest.

Getting WA but dont know

anurag_aggarwal @ 5 Apr 2010 06:18 PM

Getting WA but dont know why????

has there been any submission

calc_saransh @ 5 Apr 2010 06:50 PM

has there been any submission in java which is correct without TLE...

@ everyone.. plz tell me how

sankikhopadi @ 5 Apr 2010 09:14 PM

@ everyone..

plz tell me how to get the input.. like do we have take input as a string and then seperate numerator and denominators or do we have to take numerator and denominator seperately..plz reply soon...

@vishal: we can't tell you

jcomeau_ictx @ 5 Apr 2010 10:51 PM

@vishal: we can't tell you during a contest, or we'll be disqualified. you've got to figure it out on your own.

is the output evaluating

potato @ 6 Apr 2010 12:49 AM

is the output evaluating continous? so I get WA until the time limit, if I messed up something and when I reach the limit, then it's TLE?

fed up of TLE... will this

calc_saransh @ 6 Apr 2010 08:28 AM

fed up of TLE... will this work in java within the specified time.. someone answer plzz...

@saransh - My java solution

sppraveen @ 6 Apr 2010 10:31 AM

@saransh - My java solution ran within two seconds. see successful submissions list in this page. Come up with a better algorithm

Er, my java had a compilation

Tool @ 7 Apr 2010 12:23 AM

Er, my java had a compilation error but the site didn't display any cause. What the heck?

Could anyone tell how many

wiwbiz @ 7 Apr 2010 07:11 AM

Could anyone tell how many fractions are added in the problem ? In first case three fractions are used for indexing through so the output is understood. But in second case only first two fractions are indexed and then last three fractions are indexed. What's going on ?

I don't understand your

triplem @ 7 Apr 2010 07:14 AM

I don't understand your question. You want to find the maximal sum starting from each index; there is no limit on how many fractions there are in this sum.

im using c++.when i

addicted @ 7 Apr 2010 05:51 PM

im using c++.when i dynamically allocate memory using 'new' im getting a runtime error.when i use static allocation im getting time limit exceeded.wats the problem

The following people are

admin @ 7 Apr 2010 06:51 PM

The following people are being warned for discussing algos, trip and tricks, which is against the Contest Rules. Any further breach of the rules shall result in their being banned from this Contest.

Pratyush Verma
Max Weinbrown
sushant bhatia
vishal johri
Pankaj kumar
AMRITPAL SINGH
Vivek Agarwal

@admin: Why is it happening

blackBird @ 10 Apr 2010 12:47 AM

@admin:

Why is it happening that sometimes i am not able to find myself in my countrywise listing (India-wise) listing, tough i can find myself in global listing. Please reply soon.

 

I tried even refreshing the page many times and also at gaps of 5 mins. But still i am not able to find my India-wise listing.

 

My India-wise ranking is sometimes visible but sometimes NOT. Please reply soon.

"By starting at index 3, the

pratyushag @ 10 Apr 2010 05:48 PM

"By starting at index 3, the maximum sum you can obtain is 10/1 itself,"

how can that be as 10/1 + 5/4 is not equal to 10/1

it is equal to 3/1

@Pratyush: It is actually

flying_ant @ 10 Apr 2010 07:20 PM

@Pratyush: It is actually 10/1 + nothing else :) , so its 10/1. For a fraction , max fractions_sum we can get can be just that fraction itself.

" The ith line contains the

boxer @ 10 Apr 2010 07:26 PM

" The ith line contains the maximum fraction you can obtain by adding continuous fractions in the list starting at index i."

Does that mean only continuous fractions starting at i? Or the set of continuous fractions starting at i and any other *continuous* fractions.

@ADMIN PLEASE EXPLAIN THE

dabbcomputers @ 11 Apr 2010 12:41 PM

@ADMIN

PLEASE EXPLAIN THE ALGORITHM BE AFTER THE CONTEST......

ONLY MAKE THE SOLUTION PUBLIC IS NOT ENOUGH

THANX..

+1 , Yes. A good editorial

flying_ant @ 11 Apr 2010 12:48 PM

+1 , Yes. A good editorial for these monthly contests would be very helpful for many interested people.

@Abhijit K and @Amrtipal

anup @ 12 Apr 2010 10:25 AM

@Abhijit K and @Amrtipal Singh,

We shall be publishing a short writeup discussing the Algorithm after the Contest from this contest onwards. Thanks for pointing it out though.

@Saket are you still facing the same problem?

I literally just submitted a

Tool @ 12 Apr 2010 02:13 PM

I literally just submitted a program that simply takes the input and spits it back out,  and I get TLE.

Can this seriously be done in java?

Yes.

triplem @ 12 Apr 2010 02:16 PM

Yes.

@anup kalbalia... are u

dabbcomputers @ 12 Apr 2010 11:53 PM

@anup kalbalia...

are u admin.......??? or member of directi...??

Even with the lower bound on

Tool @ 13 Apr 2010 12:43 AM

Even with the lower bound on runtime (just Input to output) being insufficient? Preposterous.

@Tedrick There is one

imrankane2005 @ 13 Apr 2010 02:31 AM

@Tedrick

There is one Accepted java solution for this problem.

Which is baffling given that

Tool @ 13 Apr 2010 02:54 AM

Which is baffling given that a straight up I/O regurgitation doesn't run within the time limit.

But props to the person with the java solution.

If your method of

triplem @ 13 Apr 2010 03:03 AM

If your method of reading/writing exceeds the time limit then clearly your method of reading/writing is too slow. There isn't anything else one can say.

Unless there's a faster

Tool @ 13 Apr 2010 05:24 AM

Unless there's a faster method than using BufferedReader and System.out (which i've been told there isn't), i hold nothing but contempt for this. I thought this competition should test our algorithm design ability, but this doesn't appear to be the focus. If having a program run within the time limit requires submitting when the server isn't busy, I believe we have a right to complain. One or two correct submissions isn't convincing when the rest are possibly encountering unreconcilable circumstances.

Ya, true. May be, while

flying_ant @ 13 Apr 2010 08:52 AM

Ya, true. May be, while setting the problems.. writer & testers should run the program in java and decide the 'java time limit' ,  specific to each problem. Just a 2x may not work in case of huge i/o . If there are very fast i/o methods/tricks , admins should consider writing a neat tutorial about it, and allow others to use codefragments from that.

@Amrtipal Singh: I am an

anup @ 13 Apr 2010 11:44 AM

@Amrtipal Singh: I am an admin and a part of DirectI as well.

@Tedrick and @Anil Kishore: As there is one accepted Java Solution, we feel time limits are not an issue.

@Tedrick: I got Accepted in

imrankane2005 @ 13 Apr 2010 02:52 PM

@Tedrick: I got Accepted in JAVA too without needing any special Input/Output Optimization, so as admin clearly said there is no language issues in this.

@Stephen Merriman can u

vishal gupta MSP @ 13 Apr 2010 04:07 PM

@Stephen Merriman

can u please send me the code of Adding Fractions and Trip at vishalguptamsp@gmail.com ..

I would be ever thankful to you...

All contest submissions will

triplem @ 13 Apr 2010 04:37 PM

All contest submissions will be made public in the next couple of days.

My Java solution is TLE even

dttri @ 13 Apr 2010 05:21 PM

My Java solution is TLE even I just read the input and output dummy value, no computation.

@anup kalbalia: does the running time depend on how busy the server is? If yes, one accepted Java solution mean nothing.

@anup kalbalia Thanx for your

dabbcomputers @ 13 Apr 2010 07:37 PM

@anup kalbalia

Thanx for your support.

sir i am new to programming and i want to learn programming. At this time i have  no enough knowledge to solve these great problems. so sir by posting a note on algos used in problem, u can help us.

and by this way this site would be work as learning platform rather than competition site.

THANK YOU VERY MUCH.

@stephen wats ur job???? dont

vishal gupta MSP @ 13 Apr 2010 08:53 PM

@stephen

wats ur job???? dont u hav nethitng good to do other than acting like a admin at codechef?? better go and do some good job...

Please tell me if all the

rajatag12 @ 13 Apr 2010 09:05 PM

Please tell me if all the accepted solutions will pass the test case which has 100000 input fractions denoted by,

x/y, where x = 100000 to 1 and y = 100000 for all y. (should mostly time out)

x/y, where x = 1 to 100000 and y = 100000 for all y, (should produce overflow error even for long)

Thinking of such test case, i didn't submit a code with the accepted approach.

Please correct me if i am worng, coz it seems the problem statement poses unncesary constraints for input values while the intended solution is not really desired to meet them. Weak test cases!

The intended solution passes

triplem @ 14 Apr 2010 06:56 AM

The intended solution passes those test cases easily.

May be admins should add one

flying_ant @ 14 Apr 2010 12:04 PM

May be admins should add one more rule to disqualification rules , 'who ever comments anything bad or against stephen will be banned !' .

.

Thanks Stephen for all the time you put in here. It helps many people ( participants and admins :) ).

Well, it might me my system.

rajatag12 @ 14 Apr 2010 12:42 PM

Well, it might me my system. But some of the accepted solutions, that used int type variable for storing fractions give negative fractions as output. Which i do not think is the correct behaviour.

(ran the codes on test case x/y, x = 1 to 100000, y = 100000)

We definitely appreciate

admin @ 15 Apr 2010 06:08 PM

We definitely appreciate Stephen's contribution :)

hello friends, i am reading

cooltodinesh @ 17 Apr 2010 04:00 AM

hello friends,

i am reading problems on this website since last 6 months.

i love to solve them on paper. but when it comes to 'C' (my fav  lang), i always go with TLE error, even i optimie code to least.

plz help me what was wrong in my submission to this problem. i got TLE. check my soln ID 222754

and help me please.

@ Stephen Merriman: hello , u really do good in all man!!! please i expect u to check my solution and once let me kno wat was wrong so i can join next month with joy n spirit..

waiting for replies...

 

The problem is that you

triplem @ 17 Apr 2010 04:09 AM

The problem is that you believe you have solved it on paper when you haven't. You algorithm has two nested loops going up to n - but n can be up to 100000. It is simply impossible to have that sort of algorithm run in time regardless of any optimisation you do. There was no point in writing any code in the first place.

You need to think of an algorithm on paper that does not require n^2 operations. That is the whole point of this problem - if n could only go up to 1000 then it would be very easy. Once you have done that, then you can start writing code.

@admin When will the rantings

abhijith @ 17 Apr 2010 08:02 AM

@admin

When will the rantings be updated ?

thanks stefen

cooltodinesh @ 18 Apr 2010 12:44 AM

thanks stefen

@ admin.. On topcoder rating

mcsharma1990 @ 20 Apr 2010 10:07 PM

@ admin..

On topcoder rating is updated within an hour after the contest ends.

Why you people do not update rankings on time? I don,t thing that its that difficult to do that within 1-2 days. Still you take about 10-15 days?

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com