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 的时间检查整个打出来的字符串,并且 ...
随机推荐
- HDOJ2023求平均成绩
求平均成绩 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- C标准库函数实现之strstr(转)
看下Linux下的实现: char *strstr(const char *s1, const char *s2) { size_t l1, l2; l2 = strlen(s2); if (!l2) ...
- sql server 判断日期当前月有多少天
declare @tm datetime set @tm = CONVERT(datetime,'2013-3-12')declare @days intselect @days = case whe ...
- 使用gulp脚本配合TypeScript开发
目标:编写TypeScript时,保存即生成js文件. 使用npm安装以下组件 gulp gulp-rename through-gulp gulp-typescript 编写gulpfile ...
- 使用httpclient发送post请求与get请求
最近因为项目的要求,需要使用httpclient来发送请求.但是查阅了许多博客,大家发送请求的方法各不相同.原因是因为httpclient的jar包的不同版本,其内部方法也不相同.因此抛开具体用到的j ...
- Word中批量替换软回车
在平时工作中,有时候需要拷贝一些截取自网页上的文字,当选中后拷贝到Word中时,有时候在每行的结尾出现如下的符号,,这给后期文字的整理带来了很多不便,在此记录从网上获取的解决方法,以免遗忘和便于查找. ...
- iOS开发基础之排序
Objective-C 有排序的API,省了我们很多事. 主要有以下3种方法. NSComparator NSArray *unsortedArray = @[@5,@3,@8,@1,@7]; NSA ...
- linux网络编程九:splice函数,高效的零拷贝
from:http://blog.csdn.net/jasonliuvip/article/details/22600569 linux网络编程九:splice函数,高效的零拷贝 最近在看<Li ...
- linux ubuntu 思源黑体安装
下载地址: 全部:700多M https://github.com/adobe-fonts/source-han-sans/releases/tag/1.001R 可选部分Github : http ...
- 带搜索的下拉框Chosen
一:参考 https://harvesthq.github.io/chosen/ Chosen是一个jQuery插件 二:引入js文件 <link href="plug-in/chos ...