UVA - 11100 The Trip, 2007 贪心
来源:互联网 发布:一加该网络 编辑:程序博客网 时间:2024/06/11 00:01
题目大意:有一系列的包,小的包可以放在大的包里面,要求包的数量最少,而且在外面的包的大小最少
解题思路:尺寸一样的包的最多的数量就是包的数量,因为不能出现相同的包在同一个包里面的情况,得出包的数量后,以其为跳跃点,进行装包,因为在最大数量的跳跃点不可能出现两个包相同的
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 10000 + 5;int bags[maxn];int main() {int n;int mark = 0;while(scanf("%d", &n) && n) {if(mark)printf("\n");elsemark = 1;for(int i = 0 ; i < n; i++)scanf("%d",&bags[i]);int sum = 1;int max = 1;sort(bags,bags+n);for(int i = 1; i < n; i++) {if(bags[i] == bags[i-1])sum++;elsesum = 1;if(sum > max)max = sum;}printf("%d\n",max);for(int i = 0; i < max ;i++) {for(int j = i; j < n; j = j + max) {printf("%d",bags[j]);if(j+max < n)printf(" ");}printf("\n");}}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 111100 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
- CentOS英文环境下使用中文输入法
- LCS之poj1080
- 图书馆管理系统测试计划说明书
- OpenCV成长之路(7):图像滤波
- lenovo G480 安装无线驱动 linux
- UVA - 11100 The Trip, 2007 贪心
- OpenCV成长之路(6):数学形态学基本操作及其应用
- JavaWeb——Day12_1
- [java]范型
- centos 6.5 关闭触控板
- 第十一周项目一——函数星号图(2)
- Codeforces 30D King's Problem? 模拟
- OpenCV成长之路(5):图像直方图的应用
- M$PSZI$Y是什么意思