Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
Notar que: "A combination of courses is considered
most popular
if no other combination has higher
popularity."
Con esto podemos preguntarnos ¿Si hay empate entre varias combinanciones?
Entrada:
10
100 200 300 400 444
444 100 200 300 400
100 300 400 444 200
100 200 400 444 300
100 444 200 300 400
111 222 333 444 455
222 333 444 455 111
222 333 455 111 444
455 111 222 333 444
111 222 444 455 333
0
Salida:
10
**/
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <sstream>
#include <map>
using namespace std;
int f,maxi;
int A[5];
string s;
stringstream ss;
int main(){
scanf("%d",&f);
while(f){
maxi=0;
map <string,int> M;
int aux=f;
while(f--){
for(int i=0;i<5;i++){
scanf("%d",&A[i]);
}
sort(A,A+5);
ss.str(""); //si no se limpia se queda el buffer almacenado con el anterior
for(int i=0;i<5;i++)
ss << A[i]; //a es tipo int, c tipo string
s = ss.str();
M[s]++;
maxi=M[s]>maxi?M[s]:maxi;
}
if(maxi==1)
printf("%d\n",aux);
else{
int res=0;
for(auto i=M.begin();i!=M.end();i++){
if(i->second==maxi)
res++;
}
printf("%d\n",maxi*res);
}
scanf("%d",&f);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.