Skip to content

Instantly share code, notes, and snippets.

@veigavitor
Created January 29, 2023 17:22
Show Gist options
  • Save veigavitor/e6d5bb5f79fb79d07373d8dfca8174d5 to your computer and use it in GitHub Desktop.
Save veigavitor/e6d5bb5f79fb79d07373d8dfca8174d5 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// vetor que vai comportar as pontuações
vector<int> v(5);
for(int i = 0; i < 5; i++) {
cin >> v[i];
}
// ordenamos o vetor do maior para o menor valor
sort(v.rbegin(), v.rend());
// a pontuação do troféu será a maior do vetor
int vtrofeu = v[0], vplaca = -1;
for(int i = 0; i < 5; i++) {
if(v[i] != vtrofeu) {
// a pontuação da placa será a segunda maior do vetor
vplaca = v[i];
break;
}
}
int trofeus = 0, placas = 0;
// contamos agora quantos troféus e quantas placas existem
for(int i = 0; i < 5; i++) {
if(v[i] == vtrofeu) trofeus++;
if(v[i] == vplaca) placas++;
}
cout << trofeus << " " << placas << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment