总是拆最短的链子  连接长的链子   贪心....

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std; int a[110];
int main()
{
int n;
scanf("%d",&n);
for(int i = 0; i < n; i++)
scanf("%d",&a[i]);
int i = 0, j = n-1, t = 0;
sort(a, a+n);
while(i < j)
{
a[i]--;
j--;
if(a[i] == 0)
i++;
t++;
}
printf("%d\n",t);
return 0;
}

SGU 186的更多相关文章

  1. SGU - 186 - The Chain (贪心)

    186. The Chain time limit per test: 0.25 sec. memory limit per test: 4096 KB input: standard input o ...

  2. SGU 186.The Chain

    看懂题就是水题... code #include <iostream> #include <algorithm> using namespace std; int a[110] ...

  3. 今日SGU 5.26

    #include<bits/stdc++.h> #define de(x) cout<<#x<<"="<<x<<endl ...

  4. SGU 分类

    http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...

  5. SGU 495. Kids and Prizes

    水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...

  6. ACM: SGU 101 Domino- 欧拉回路-并查集

    sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Desc ...

  7. 【SGU】495. Kids and Prizes

    http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...

  8. SGU 455 Sequence analysis(Cycle detection,floyd判圈算法)

    题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=455 Due to the slow 'mod' and 'div' operati ...

  9. SGU 422 Fast Typing(概率DP)

    题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...

随机推荐

  1. Ajax-Demo

    index.jsp 1 <%@ page language="java" contentType="text/html; charset=UTF-8" p ...

  2. T-SQL 使用链接库向mysql导数据遇到的奇葩事件一

    mysql表结构有 主键 非自增 text longtext类型字段多个 步骤 1.在T-SQL 临时表中处理好所有需要的字段 2.执行openquery语句 字段顺序完全按照mysql字段顺序插入 ...

  3. 如何让Asp.net webAPI返回JSON格式数据

    ASP.NET Web API 是新一代的 HTTP 網路服務開發框架,除了可以透過 Visual Studio 2012 快速開發外 (內建於 ASP.NET MVC 4 的 Web API 專案範 ...

  4. Oracle 10g设置IP访问限制

    出于数据安全考虑,对Oracle数据库的IP做一些限制,只有固定的IP才能访问. 修改 db_1/NETWORK/ADMIN/sqlnet.ora文件 增加以下内容(红色表示注释): #开启ip限制功 ...

  5. 创建Mysql 序列

    create table sequence( name ) not null primary key, current_value , increment , max_value BIGINT, -- ...

  6. Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载五)Linux系统的对话方式

    本篇是Linux小白最佳实践第5篇,目的就是让白菜们了解Linux进程之间是如何对话的.之前连载的几篇,在微信上引起了很多的反响,有人也反映图多文字少,感觉没有干货.本篇选了大部分是实战讲解的&quo ...

  7. Javascript基本格式

    Javascript基本格式 ① JavaScript区分大小写 只要一门语言是面向对象的,其都是区分大小写,所以在Javascript中,变量小i与变量I是两个完全不同的变量 ② JavaScrip ...

  8. [zz]安装PostgreSQL数据库(Linux篇)

    0.编译环境 Linux: CentOS 5.5 gcc: 4.1.2 1. 安装PostgreSQL 1) 解压postgresql-9.1.7.tar.bz2 #tar jxvf postgres ...

  9. Polyline转Polygon

    IGeometry geo = feature.ShapeCopy; IGeometryCollection pPolyline = geo as IGeometryCollection; ISegm ...

  10. IPoint从自定义的投影坐标系转换到自定义的地理坐标系

    IPoint pointStart = new PointClass(); pointStart = xyPolyline.FromPoint; ISpatialReferenceFactory pS ...