UVa 11286 - Conformity
来源:互联网 发布:彩票数据分析软件 编辑:程序博客网 时间:2024/06/05 06:38
题目:选课系统,每个人选5门课,如果很多人选择相同5门课认为这个组合比较热门,
现在要求出选择最热门课程组合的选择人数。
分析:数据结构,STL。对每组数据先排序,然后利用map统计求解即可。
(也可以使用hash表或者利用long long压缩排序统计)
说明:如果有很多人们组合,都算在一起。
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstdio>#include <map>typedef long long LL;using namespace std;int courses[5];int main(){int n;while (cin >> n && n) {map<LL, int> Map;int maxv = 1, count = 0;for (int t = 0; t < n; ++ t) {for (int i = 0; i < 5; ++ i)cin >> courses[i];sort(courses, courses+5);LL value = 0LL;for (int i = 0; i < 5; ++ i) {value *= 1000;value += courses[i];}maxv = max(maxv, Map[value] += 1);}for (map<LL, int>::iterator it = Map.begin(); it != Map.end(); ++ it)if (it->second == maxv) count += maxv;cout << count << endl;} return 0;}
0 0
- UVa 11286 - Conformity
- 【hash】Conformity
- POJ 3640 Conformity
- Sicily 1453. Conformity
- POJ 3640 Conformity(Hash)
- POJ 3640 Conformity 可能会
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- poj 3349 Snowflake Snow Snowflakes
- objective-c 注释用法
- leetcode 89:Gray Code
- [Win32] 注册表操作(2)枚举注册表
- 为布尔方法命名
- UVa 11286 - Conformity
- [Android]使用draw9patch制作可拉伸图片
- 7月21日---关键字、抽象方法、抽象类、接口、多态及总结、设计模式
- [iOS]获取iOS UI框架中最上层的UIViewController对象
- 黑马程序员_C语言基础_关键字、printf函数、scanf函数
- 数据库分库分表方案
- javascript 对象创建,操作
- 避免双重否定
- PHP官方文档“语言参考”章节阅读摘要