*Can someone tell me why i am getting WA on 2 testcases?*

I know that it is from the current contest at CodeChef but i am asking it because it is unrated contest & INOI is nearly approaching.

I think there may be a small flaw in your logic. First of all you cannot just add sum to all values of s[i] and sort it.

For example consider this case:

2

100 1 15

1 1 1

So from your logic answer would be 103 but answer is 116.

I also implemented that logic at first only but if any of your INOI solution is not working you can see the test cases available at the IARCS website. http://www.iarcs.org.in/inoi/2012/inoi2012/triathlon-data.zip

Well I got that question in one go , the trick is to sort the participants according to their time taken in completing the 2 contests other than COBOL one , here is the implementation,

```
#include <iostream>
#include <vector>
#include <algorithm>
//Structs for more readability and storing the time
typedef struct timetaken{
int cobol;
int rest;
}timetaken;
//Sorting out in descending order according to the time taken in other 2 contests
bool compare(timetaken a, timetaken b){
return a.rest > b.rest;
}
int main(){
int n;
std::cin >> n;
std::vector<timetaken>citizens(n);
for(int i=0;i<n;i++){
timetaken a;
std::cin >> a.cobol;
int b,c;
std::cin >> b >> c;
a.rest = b+c;
citizens[i] = a;
}
sort(citizens.begin(),citizens.end(),compare);
int mintime = 0;
int prevtime = 0;
for(int i=0;i<n;i++){
int time = prevtime + citizens[i].cobol + citizens[i].rest;
//std::cout << time << ' ' << prevtime << std::endl;
if(time > mintime){
mintime = time;
}
prevtime = prevtime + citizens[i].cobol;
//std::cout << prevtime << std::endl;
}
std::cout << mintime << std::endl;
return 0;
}
```

r u solve The Triathlon Problem???