Sicily 1453. Conformity

1453. Conformity

Constraints

Time Limit: 2 secs, Memory Limit: 32 MB

Description

Frosh commencing their studies at Waterloo have diverse interests, as evidenced by their desire to take various combinations of courses from among those available.

University administrators are uncomfortable with this situation, and therefore wish to offer a conformity prize to frosh who choose one of the most popular combinations of courses. How many frosh will win the prize?

Input

The input consists of several test cases followed by a line containing 0. Each test case begins with an integer 1 ≤ n ≤ 10000, the number of frosh. For each frosh, a line follows containing the course numbers of five distinct courses selected by the frosh. Each course number is an integer between 100 and 499.

Output

The popularity of a combination is the number of frosh selecting exactly the same combination of courses. A combination of courses is considered most popular if no other combination has higher popularity. For each line of input, you should output a single line giving the total number of students taking some combination of courses that is most popular.

Sample Input

3
100 101 102 103 488
100 200 300 101 102
103 102 101 488 100
3
200 202 204 206 208
123 234 345 456 321
100 200 300 400 444
0

Sample Output

2

3

// Problem#: 1453
// Submission#: 3312955
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <set>
#include <iomanip>
#include <map>
using namespace std;



int main() {

    std::cout.sync_with_stdio(false);

    string temp;

    while (1) {

       int n;
       cin >> n;
       int MAX = -1;
       if (n == 0) break;
       map<long long int, int> counter;
       for (int i = 0; i < n; i++) {
           int a[5];
           for (int j = 0; j < 5; j++) cin >> a[j];
           sort(a, a + 5);
           long long int temp = 0;
           for (int j = 0; j < 5; j++) temp = temp * 1000 + a[j];
           if (counter.find(temp) == counter.end()) counter[temp] = 1;
           else counter[temp]++;
           MAX = max(counter[temp], MAX);
       }
       int ans = 0;
       for (map<long long int, int>::iterator iter = counter.begin(); iter != counter.end(); iter++) if (iter->second == MAX) ans += iter->second;
       cout << ans << endl;
    }


    return 0;
}                                 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值