import java.util.*;

public class Main

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

int n = in.nextInt();

int[][] ints = new int[20][5];

    for (int i = 0; i < 20; i++)
{
Arrays.fill(ints[i], 0);
} int si = 0;
for (int j = 0; j < n; j++)
{
int site = in.nextInt(); for (int i = 0; i < 20; i++)
{ if (si <= 19)
{
if (site <= foundPlace(ints[i]))
{
setPlace(ints[i], i, site);
if (si <= i)
{
si++;
}
break;
}
}
else if (si > 19)
{
if (site <= foundPlace(ints[i]))
{
setPlace(ints[i], i, site);
return;
}
else if (foundPlace(ints[i]) < site)
{
int s = foundPlace(ints[i]);
setPlace(ints[i], i, foundPlace(ints[i]));
site -= s; }
}
}
}
} /**
* @param ints
* @return 空位置数目
*/
private static int foundPlace(int[] ints)
{
int s = 0;
for (int i = 4; i >= 0 && ints[i] == 0; i--)
{
s++;
}
return s;
} /**
* @param ints
* @return
*/
private static void setPlace(int[] ints, int p, int q)
{
int qq = 0;
for (int i = 0; i < 5; i++)
{
if (ints[i] == 0 && qq < q)
{
ints[i] = p * 5 + i + 1;
qq++; System.out.print(ints[i]);
if (qq != q)
{
System.out.print(" ");
}
else if (qq == q)
{
System.out.println();
}
}
}
}

}

最新文章

  1. Python 字符串相加问题
  2. FlashFXP 破解代码
  3. css基本知识框架(转)
  4. International Conference in 2015
  5. asp.net mvc中包含webapi时,token失效产生302的解决方案
  6. 使用webdriver + phantomjs + pdfkit 生成PDF文件
  7. SQL Server 使用日志传送
  8. ubuntu安装python3
  9. 裸眼3D立体显示技术原理详解
  10. Spring MVC中注解 @ModelAttribute
  11. scp和pscp
  12. [Ext JS 4] contentEL,renderTo, applyTo 释义与区别
  13. Python学习中的一些小例子
  14. numpy初识
  15. 为什么 web 开发人员需要迁移到. NET Core, 并使用 ASP.NET Core MVC 构建 web 和 webservice/API
  16. NOIP2015提高组复赛B 子串
  17. unity中获取七天的日期
  18. 迭代器_iter_,生成器yeild,三元运算,列表解析(十三)
  19. 20. Spring Boot 默认、自定义数据源 、配置多个数据源 jdbcTemplate操作DB
  20. Netty入门(2) - 核心概念

热门文章

  1. Objective-C 中Socket常用转换机制(NSData,NSString,int,Uint8,Uint16,Uint32,byte[])
  2. poj 1274 The Perfect Stall 解题报告
  3. 【CQ18阶梯赛第二场】题解
  4. Linux命令排查线上问题常用的几个
  5. codeforces round 420 div2 补题 CF 821 A-E
  6. Eclipse全项目搜索指定文件&amp;字串
  7. UVa 1643 Angle and Squares (计算几何)
  8. 洛谷 - P1379 - 八数码难题 - bfs
  9. 洛谷 - P1004 - 方格取数 - 简单dp
  10. hdoj1789【贪心】