The Triathlon Problem

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

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:


100 1 15

1 1 1

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

1 Like

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.

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;

//Sorting out in descending order according to the time taken in other 2 contests
bool compare(timetaken a, timetaken b){
    return >;

int main(){
    int n;
    std::cin >> n;
    for(int i=0;i<n;i++){
        timetaken a;
        std::cin >> a.cobol;
        int b,c;
        std::cin >> b >> c; = b+c;
        citizens[i] = a;
    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;

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.

r u solve The Triathlon Problem???