Quick actions

cmd+k|ctrl+k

Navigation

Languages

1766 - URI

Snippet info

Language

Cpp

Visibility

public

Author

andressatheotonio

Created

2018-12-01T00:36:55Z

Updated

2018-12-01T00:36:55Z

#include <bits/stdc++.h>
using namespace std;

struct rena{
    string nome;
    int peso;
    int idade;
    double altura;
};

bool comp(rena a, rena b){
    if(a.peso != b.peso)
        return a.peso > b.peso;
    else if(a.idade != b.idade)
        return a.idade < b.idade;
    else if(a.altura != b.altura)
        return a.altura < b.altura;
    else
        return a.nome < b.nome;
}

int main() {
    int testes, tr, r, p, id;
    double a;
    vector <rena> estab;
    string s;
    
    cin >> testes;
    
    for(int i = 1; i <= testes; i++){
        cin >> tr >> r;
        
        for(int j = 0; j < tr; j++){
            cin >> s >> p >> id >> a;
            rena r1 {s,p,id,a};
            estab.push_back(r1);
        }
        
        sort(estab.begin(), estab.end(), comp);
        
        printf("CENARIO {%d}\n", i);
        
        for(int j = 0; j < r; j++){
            cout << j+1 << " - " << estab[j].nome << "\n";
        }
        
        estab.clear();
    }
    
    return 0;
}
INFO