# TRAITHLONN: getting WA

I am getting WA on the problem TRAITHLON of inoi 2012. I don’t know whether the problem is with the logic or the code. This is my logic.

1.Store the sum of pole vault time and doughnut eating tim in an array sumtime.

2.Find out the position (each position represents a person) for which sumtime is maximum provided it has not been selected earlier (i.e it has not been burnt).

3.In case of tie, consider the one with minimum cobol time (because then the delay time will be less)

4.Add the sumtime and the delay time (additional time in the code) and the cobol time and store it in the variable minrequiredtime and finally print it in the end.

My code is here:
http://ideone.com/e.js/z38pjz

I have used different logic. I got correct answer

@dikshadiksha Though it’s not a codechef’s contest(LTIME,SHORT,LONG) but still as you are new here , Do not ask or discuss or share your code in any aspect of any CodeChefs’ problem during an ongoing contest on any other platform.Discussion of strategy should be avoided during the contest and postponed till the end.
Thankyou
EDIT:- i don’t want you to be penalized unknowingly HAPPY CODING

2 Likes

PS: This is a Practice Contest , Where problems have been discussed before , They can be discussed.

This is a Greedy problem , to minimize the total time , we need to arrange the contestants in such a manner so that NO Contestant’s time is WASTED so we maximize the number of participants doing other two tasks (Pole Vault and Doughnut Eating) while one is coding in COBOL as those other two tasks can be performed simultaneously so no constraint there…

Get IT ?

Divide Time into Two Parts , let Cobol time,pole vault and doughnut be u,v,w

Sorting in decreasing order of v+w allows maximum number of people to code in COBOL while one is performing other tasks , as time will always be greater or equal to Summation of u , therefore the final answer boils down to

max of sum plus v+w for all i …

http://paste.ofcode.org/XkZnDcMGXcsW849h7abmnc

1 Like

Okay. I got the problem with my logic. It isn’t necessary that the person with minimum pole+doughnutnut time will finish last. We have to consider cobol time too. And that’s why sum of all must be added with delay time. And the person taking maximum time in this total time is the one who finished last. Thanks once again.

//