题意:有n个包,其中小包可以装到大的包里,包的大小用数字进行表示,求最小的装包数量。

析:这个题的题意不太好理解,主要是有一句话难懂,意思是让每个最大包里的小包数量的最大值尽量小,所以我们就不能随便输出了,

我们先求出最少多少包,这个肯定是相同包的的最大数目了,然后输出时用等差输出,这样就能保证题目的要求。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <unordered_map>
//#include <unordered_set>
#define debug() puts("++++");
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e4 + 5;
const int mod = 2000;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[maxn]; int main(){
int kase = 0;
while(scanf("%d", &n) == 1 && n){
int ans = 1;
for(int i = 0; i < n; ++i) scanf("%d", a + i);
sort(a, a + n);
int cnt = 1;
for(int i = 1; i < n; ++i){
if(a[i] == a[i-1]) ++cnt;
else cnt = 1;
ans = max(ans, cnt);
}
if(kase) puts("");
++kase;
printf("%d\n", ans);
cnt = 0;
while(cnt < ans){
for(int i = cnt; i < n; i += ans)
if(i == cnt) printf("%d", a[i]);
else printf(" %d", a[i]);
printf("\n");
++cnt;
}
}
return 0;
}
//

UVa 11100 The Trip, 2007 (题意+贪心)的更多相关文章

  1. UVA 11100 The Trip, 2007 (贪心)

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  2. UVA 11100 The Trip, 2007 水题一枚

    题目链接:UVA - 11100 题意描述:n个旅行箱,形状相同,尺寸不同,尺寸小的可以放在尺寸大的旅行箱里.现在要求露在最外面的旅行箱的数量最少的同时满足一个旅行箱里放的旅行箱的数量最少.求出这样满 ...

  3. UVA 11100 The Trip, 2007 贪心(输出比较奇葩)

    题意:给出n个包的大小,规定一个大包能装一个小包,问最少能装成几个包. 只要排序,然后取连续出现次数最多的数的那个次数.输出注意需要等距输出. 代码: /* * Author: illuz <i ...

  4. UVa 11100 - The Trip, 2007 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  5. UVa 11100 The Trip, 2007

    今天的教训:做题要用大块的时间来做,上午做一下,做题做到一半就去忙别的事,那么后面再做的时候就无限CE,WA了.因为你很难或者需要很长时间来找回当时的思路. 题意:就像套瓷娃娃一样,有n个包,大小可能 ...

  6. Uva 11729 Commando War (简单贪心)

    Uva 11729  Commando War (简单贪心) There is a war and it doesn't look very promising for your country. N ...

  7. uva 1153 顾客是上帝(贪心)

    uva 1153 顾客是上帝(贪心) 有n个工作,已知每个工作需要的时间q[i]和截止时间d[i](必须在此前完成),最多能完成多少个工作?工作只能串行完成,第一项任务开始的时间不早于时刻0. 这道题 ...

  8. The trip(Uva 11100)

    题目大意: 给出n个数,要求将其分成最少的递增序列,保证序列最少的同时要使得序列长度的最大值最小.  n<=10000 题解: 1.我是直接看着<训练指南>里的中文题面的,lrj似乎 ...

  9. UVa 11100 旅行2007

    https://vjudge.net/problem/UVA-11100 题意: 给定n个正整数,把它们划分成尽量少的严格递增序列,尽量均分. 思路: 因为必须严格递增,所以先统计每个数字出现的次数, ...

随机推荐

  1. lamp环境的搭建和配置

    安装apache httpd-2.2.31.tar.gz rpm -qa|grep httpd   ##卸载旧的httpd httpd--.el6.centos.x86_64 httpd-tools- ...

  2. Django一对多的创建

    1.一对多的应用场景: 例如:创建用户信息时候,需要选择一个用户类型[普通用户][金牌用户][铂金用户]等. 2.方法: class Business(models.Model): buss=mode ...

  3. SpringBoot学习笔记(1):配置Mybatis

    SpringBoot学习笔记(1):配置Mybatis 反思:如果自己写的笔记自己都看不懂,那就不要拿出来丢人现眼! IDEA插件 Free MyBatis Plugin插件可以让我们的MyBatis ...

  4. 吴恩达机器学习笔记(十一) —— Large Scale Machine Learning

    主要内容: 一.Batch gradient descent 二.Stochastic gradient descent 三.Mini-batch gradient descent 四.Online ...

  5. 51nod 1537

    题目 神犇题解 证明好巧妙,给跪OTZ 题目的式子:$ {\left( {1{\rm{ + }}\sqrt 2 } \right)^{\rm{n}}} $,设其乘开之后为 $ {\rm{a + b}} ...

  6. Contiki clock模块

    一.functions for handling system time clock_time_t clock_time(void);//return the current system time ...

  7. Linux学习之路(二)文件处理命令之上

    文件处理命令 1.目录处理命令 2.文件处理命令 3.链接命令 1.目录处理命令 建立目录:mkdirmkdir -p [目录名]-p 递归创建命令英文原意 : make directories 切换 ...

  8. iOS开发 - 如何跳到系统设置里的各种设置界面

    在iOS开发中,有时会有跳转系统设置界面的需求,例如提示用户打开蓝牙或者WIFI,提醒用户打开推送或者位置权限等.在iOS6之后,第三方应用需要跳转系统设置界面,需要在URL type中添加一个pre ...

  9. RAC环境下控制文件损坏重建过程

    处理过程参考了: https://blogs.oracle.com/Database4CN/entry/%E5%A6%82%E4%BD%95%E9%87%8D%E5%BB%BArac%E7%9A%84 ...

  10. Java微信公众平台开发_03_消息管理之被动回复消息

    GitHub源码:https://github.com/shirayner/weixin_gz 一.本节要点 1.回调url 上一节,我们启用服务器配置的时候,填写了一个服务器地址(url),如下图, ...