PAT甲题题解-1125. Chain the Ropes (25)-贪心水题
贪心水题,每次取最短的两个绳子合并,长度缩减成一半
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
using namespace std;
const int maxn=+;
int a[maxn];
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<n;i++)
cin>>a[i];
sort(a,a+n);
float lastlen=a[];
for(int i=;i<n;i++){
lastlen=(lastlen+a[i])/;
}
printf("%d\n",(int)lastlen);
return ;
}
PAT甲题题解-1125. Chain the Ropes (25)-贪心水题的更多相关文章
- PAT甲级 1125. Chain the Ropes (25)
1125. Chain the Ropes (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...
- PAT甲题题解-1012. The Best Rank (25)-排序水题
排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...
- PAT甲题题解-1062. Talent and Virtue (25)-排序水题
水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...
- 1125. Chain the Ropes (25)
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fo ...
- PAT 1125 Chain the Ropes[一般]
1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...
- 1125 Chain the Ropes (25 分)
1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...
- PAT 1125 Chain the Ropes
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fo ...
- PAT甲题题解-1008. Elevator (20)-大么个大水题,这也太小瞧我们做题者的智商了
如题... #include <iostream> #include <cstdio> #include <algorithm> #include <cstr ...
- PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚
n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...
随机推荐
- 卸载CocoaPods
1. 移除pod组件 这条指令会告诉你Cocoapods组件装在哪里 : $ which pod 你可以手动移除这个组件 : $ sudo rm -rf <path> 2.移除 RubyG ...
- beta冲刺————第四天(4/5)
完善的具体内容: 前端:以下的功能还未完全实现 (1)点击收藏可以收藏入收藏夹 (2)分享操作,意见反馈 后端: 寻找文章来源,像数据库中增添了150篇的新文章.(我们的文章都要求自己内部人员看过,所 ...
- Sqlserver数据库还原一直显示“正在还原…”解决方法
--恢复并且回到可访问状态,要执行 RESTORE database 数据库名 with recovery
- IIS 注册Asp.net 4.0
32位的Windows:---------------------------------------------------------------------------1. 运行->cmd ...
- Math.min() / Math.max() 使用方法
首先弄懂apply 和 call 都是js函数自带的方法.区别如下: apply和call的用法只有一个地方不一样,除此之外,其他地方基本一模一样 1. a.call(b,arg1,arg2…) 2. ...
- 基于duxshop遍历无限级分销用户的纵向递归
/**获取基准数据 * @param $ids 父id 多个逗号分隔 * @return array */ public function saleBase($ids) { $data=$this-& ...
- BZOJ3233:[AHOI2013]找硬币(DP)
Description 小蛇是金融部部长.最近她决定制造一系列新的货币.假设她要制造的货币的面值为x1,x2,x3… 那么x1必须为1,xb必须为xa的正整数倍(b>a).例如 1,5,125, ...
- PHP中全局变量global和$GLOBALS[]的区别分析
$GLOBALS['var']是外部的全局变量本身,global $var是外部$var的同名引用或者指针 一.举例比较 例一: 复制代码 代码如下: <?php $var1 = 1; ...
- Kafka学习之路 (五)Kafka在zookeeper中的存储
一.Kafka在zookeeper中存储结构图 二.分析 2.1 topic注册信息 /brokers/topics/[topic] : 存储某个topic的partitions所有分配信息 [zk: ...
- Maven搭建私服
为什么要搭建私服?搭建私服有什么好处? 以我最近技术调研和相关的使用为起点概述: 首先说明,为什么要搭建私服? 搭建私服的目的是,通常企业项目开发,特别是使用maven作为项目管理,现在非常流行使用m ...