UVA - 11100 The Trip, 2007
来源:互联网 发布:王者霸域 纯净数据库 编辑:程序博客网 时间:2024/04/29 01:49
题目大意:有n个包,大包能套小包,问最多能套成几个。
解题思路:贪心,数量最多的包肯定作为基准个数,然后去套即可。
#include <iostream>#include <algorithm>using namespace std;int main() {int n;while (cin >> n && n) {int A[10005] = {0};for (int i = 0; i < n; i++)cin >> A[i];sort(A, A + n);int cur = 0, MAX = 0;for (int i = 1; i <= n; i++)if (A[i] != A[i-1]) {MAX = max(MAX, i - cur);cur = i;}cout << MAX << endl;for (int i = 0; i < MAX; i++) {cout << A[i];for (int j = i + MAX; j < n; j += MAX)cout << " " << A[j];cout << endl;}}return 0;}
0 0
- UVA 11100 The Trip, 2007
- UVa 11100 - The Trip, 2007
- UVa 11100 - The Trip, 2007
- uva 11100 - The Trip, 2007
- uva 11100 - The Trip, 2007
- UVA 11100 - The Trip, 2007
- uva 11100 The Trip, 2007
- UVA 11100 - The Trip, 2007
- UVa:11100 The Trip, 2007
- uva 11100 The Trip, 2007
- UVa 11100 - The Trip, 2007
- UVA - 11100 The Trip, 2007
- uva--11100The Trip, 2007
- UVA 11100 The Trip, 2007
- UVA - 11100 The Trip, 2007
- UVa 11100 - The Trip, 2007
- uva 11100 The Trip, 2007
- uva 11100 The Trip, 2007
- UVA - 10891 Game of Sum
- php 匹配/r/n 回车换行特殊符号
- IntentFilter
- UVA - 10905 Children's Game
- Ubuntu14.04配置php-5.6.6开发环境
- UVA - 11100 The Trip, 2007
- UVA - 1450 Airport
- UVA - 1418 WonderTeam
- 用Scrapy爬取所有上市公司的股票代码和名称
- UVA - 11462 Age Sort
- UVA - 11549 Calculator Conundrum
- Android自定义标题栏
- UVA - 1121 Subsequence
- 迟来的再见——2014年总结