COINFLIP [tle]

,

what’s error in this code… showing too much memory(955.5M) at codechef… here is the link…

http://www.codechef.com/viewsolution/2182857

1 Like

memory is not the issue…this problem is a math problem…u don’t need to iterate through arrays to flip the coins…!!!

go through the editorial.

this should be ur algo

if (!(n&1)||i==q)
    cout<<(N/2)
else
    cout<<(N/2)+1
1 Like

U are taking the input n and allocating an array of size n… in the constraints given, n can be 10^9 and now if u want to allocate memory for an array of size 10^9 means u need 4gb :slight_smile: :wink: U can’t do that in a 32 bit system … moreover as kunal already told… Ur algo results in tle :slight_smile: change the algo

3 Likes

This was my first ever submission to long contests at Codechef. Here, you can read it, if you want.

The problem does not require you to do all the things that you are doing. It is simple, and try to analyze and break the problem into simple cases. You will hit the bull’s eye. :slight_smile:

1 Like

i got it… but what’s wrong with my logic…

you can do it by that…but it will take a lot of time…so it will not complete in the time allotted…so u get a Time Limit Exceeded(TLE) verdict!!!

50000 Bytes is the memory limit for the source code, meaning your source code should not have more than 50000 Bytes.

2 Likes

bull’s eyes… yes :slight_smile: :slight_smile: thankyou @bugkiller

as @junior94 has said the above ans is wrong…50000 bytes are for ur source code…!!!
@rakeshbubli143 dude u may have often created integer arrays of size 10^6 or greater that is more than 50000 bytes…didnt u ever notice…:stuck_out_tongue:

Oops my bad :smiley: :slight_smile: