SGU 186
总是拆最短的链子 连接长的链子 贪心....
#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的更多相关文章
- SGU - 186 - The Chain (贪心)
186. The Chain time limit per test: 0.25 sec. memory limit per test: 4096 KB input: standard input o ...
- SGU 186.The Chain
看懂题就是水题... code #include <iostream> #include <algorithm> using namespace std; int a[110] ...
- 今日SGU 5.26
#include<bits/stdc++.h> #define de(x) cout<<#x<<"="<<x<<endl ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- SGU 495. Kids and Prizes
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...
- ACM: SGU 101 Domino- 欧拉回路-并查集
sgu 101 - Domino Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Desc ...
- 【SGU】495. Kids and Prizes
http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...
- 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 ...
- SGU 422 Fast Typing(概率DP)
题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...
随机推荐
- sqlserver之二进制和字符串sql语句
正常情况下我们对数据库的操作就是如下的写法来操作数据库 ID AS 编号,BookName AS 书名 FROM dbo.books ORDER BY ID; ; 但是在客户正在使用的数据库里,我们开 ...
- Eclipse插件checkstyle 代码风格的检查
插件checkstyle 的安装 方法一: 1.Eclipse中,选择Help->Software Updates->Find and Install 2.选择 Search for ...
- Objective-C 【单个对象内存管理(野指针&内存泄露)】
------------------------------------------- 单个对象内存管理 (1)野指针 ①定义了一个指针变量,但是并没有赋初值,它随机指向一个东西 ②某指针变量指向的内 ...
- javascript的排序算法
已经准备秋招一段时间了,因为这个关系也在各种巩固知识,顺便整理一下一些东西.这篇文章就是自己整理了一下各种JS的排序算法,以便自己以后回顾. 冒泡排序 function bubbleSort(arr) ...
- jvmstat监控jvm内存
1.下载jvmstat-3_0.zip: 2.配置环境变量JVMSTAT_JAVA_HOME为jdk目录E:\Program Files\Java\jdk1.5.0_12 3.监控本机: jps查看 ...
- Polyline转Polygon
IGeometry geo = feature.ShapeCopy; IGeometryCollection pPolyline = geo as IGeometryCollection; ISegm ...
- Windows下Android模拟环境的搭建
- poj 2431 Expedition
Expedition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12980 Accepted: 3705 Descr ...
- 升级ssh编译错误
升级ssh 编译的时候遇到PAM headers not found,然后需要安装 pam-devel-1.1.1-20.el6.x86_64,自己下载了rpm包,安装报错,然后用yum -y ins ...
- NSS_02 日志配置
采用log4net,使用系统推荐的最新版本:log4net-1.2.11-bin-newkey.zip(网址:http://logging.apache.org/log4net/download_lo ...