内存不够用,用计数排序可以解决问题。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#include<algorithm>
#include<stack>
#include<queue>
#include<cctype>
#include<sstream>
using namespace std;
#define pii pair<int,int>
typedef long long int LL;
const double eps=1e-;
const int INF=;
const int maxn=+;
int c[],n,x;
int main()
{
//freopen("in1.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(scanf("%d",&n)==&&n)
{
memset(c,,sizeof(c));
for(int i=; i<n; i++)
{
scanf("%d",&x);
c[x]++;
}
int first=;
for(int i=; i<=; i++)
{
//cout<<"c"<<i<<':'<<c[i]<<endl;
if(c[i]>)
{
while(c[i]--)
{
if(first==)
{
first=;
printf("%d",i);
}
else
{
printf(" %d",i);
}
}
}
}
printf("\n");
}
return ;
}

11462 Age Sort(计数排序)的更多相关文章

  1. Uva-------(11462) Age Sort(计数排序)

    B Age Sort Input: Standard Input Output: Standard Output   You are given the ages (in years) of all ...

  2. counting sort 计数排序

    //counting sort 计数排序 //参考算法导论8.2节 #include<cstdio> #include<cstring> #include<algorit ...

  3. UVA 11462 Age Sort(计数排序法 优化输入输出)

    Age Sort You are given the ages (in years) of all people of a country with at least 1 year of age. Y ...

  4. ACM比赛(11462 Age Sort)

    You are given the ages (in years) of all people of a country with at least 1 year of age. You know t ...

  5. UVa 11462 Age Sort

    解题报告:给若干个居民的年龄排序,年龄的范围在1到100之间,输入的总人数在0到200W.这题要注意的输入的文件约有25MB,而内存限制为2MB,所以如果人数是像200W这样多的话,甚至都不能把它们都 ...

  6. COGS 1406. 邻居年龄排序[Age Sort,UVa 11462](水题日常)

    ★   输入文件:AgeSort.in   输出文件:AgeSort.out   简单对比时间限制:1 s   内存限制:2 MB [题目描述] Mr.Zero(CH)喜闻乐见地得到了一台内存大大增强 ...

  7. 计数排序(Count Sort )与插入排序(Insert Sort)

    计数排序法:计数数组适用于当前数组密集的情况.例如(2,3,5,4,2,3,3,2,5,4) 方法:先找出最大值最小值,之后统计每个数出现的次数,根据次数从小到大往数组里添加 计数排序法是一种不需要比 ...

  8. 《算法导论》——计数排序Counting Sort

    今天贴出的算法是计数排序Counting Sort.在经过一番挣扎之前,我很纠结,今天这个算法在一些scenarios,并不是最优的算法.最坏情况和最好情况下,时间复杂度差距很大. 代码Countin ...

  9. 计数排序与桶排序(bucket sort)

    Bucket Sort is a sorting method that subdivides the given data into various buckets depending on cer ...

随机推荐

  1. 在像Angular2这样的SPA应用中使用Google Analytics的方法

    Angular2のようなシングルページアプリケーションでGoogleアナリティクスを使う方法 如何在像Angular2这样的SPA应用中使用Google Analytics? 试着调查了一下. 由于S ...

  2. python常用模块——time模块

    参考博客:http://blog.csdn.net/SeeTheWorld518/article/details/48314501 http://www.jb51.net/article/49325. ...

  3. Nginx常用命令(加入系统服务)

    nginx 服务器重启命令,关闭 nginx -s reload :修改配置后重新加载生效 nginx -s reopen :重新打开日志文件 nginx -t -c /path/to/nginx.c ...

  4. 47求1+2+3+...+n

    题目描述 求1+2+3+...+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字及条件判断语句(A?B:C). 用递归 public class Soluti ...

  5. Linux环境下的图形系统和AMD R600显卡编程(1)——Linux环境下的图形系统简介

    转:https://www.cnblogs.com/shoemaker/p/linux_graphics01.html Linux/Unix环境下最早的图形系统是Xorg图形系统,Xorg图形系统通过 ...

  6. HTML table元素

    搬运,内容来自HTML Dog. 简单示例 <!DOCTYPE html> <html> <body> <table> <tr> <t ...

  7. Java开发者或许应该经常去看看的网站?...

    Java开发者或许应该经常去看看的网站?...Google top3 1.Oracle Technology Network for Java Developers | Oracle Technolo ...

  8. Apache2.4整合tomcat8

    1,编译mod_jk.so 不同版本apache对应不同的mod_jk,试验用tomcat-connectors-1.2.41-src.tar.gz , 下载后,解压,进入./native文件夹依次输 ...

  9. Xamarin简介与Xamarin支持MVC设计模式

    Create Native iOS, Android,Mac and Windows apps in C#. 官方网站:http://xamarin.com/ 使用武器 Run a C# app, g ...

  10. ACM训练小结-2018年6月19日

    今天题目情况如下:  A题:考察图论建模+判割点.B题:考察基础数据结构的运用(STL).C题:考察数学建模+运算.(三分可解)D题:考察读题+建模+数据结构的运用.E题:考察图论+贪心.F题:考察图 ...