Skip to content

Instantly share code, notes, and snippets.

@nomarlo
Created August 21, 2015 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomarlo/81a58a316a89cd749388 to your computer and use it in GitHub Desktop.
Save nomarlo/81a58a316a89cd749388 to your computer and use it in GitHub Desktop.
/**
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