贪心水题,每次取最短的两个绳子合并,长度缩减成一半

#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)-贪心水题的更多相关文章

  1. PAT甲级 1125. Chain the Ropes (25)

    1125. Chain the Ropes (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...

  2. PAT甲题题解-1012. The Best Rank (25)-排序水题

    排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...

  3. PAT甲题题解-1062. Talent and Virtue (25)-排序水题

    水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  4. 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 ...

  5. PAT 1125 Chain the Ropes[一般]

    1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...

  6. 1125 Chain the Ropes (25 分)

    1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...

  7. 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 ...

  8. PAT甲题题解-1008. Elevator (20)-大么个大水题,这也太小瞧我们做题者的智商了

    如题... #include <iostream> #include <cstdio> #include <algorithm> #include <cstr ...

  9. PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

    n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...

随机推荐

  1. CSS居中布局

    一:水平居中方案: 1.行内元素 设置 text-align:center 2.定宽块状元素 设置 左右 margin 值为 auto 3.不定宽块状元素 a:在元素外加入 table 标签(完整的, ...

  2. 用scp命令来通过ssh传输文件,ssh推送.py程序到CentOS7服务器端出现lost connection错误

    ssh推送.py程序到CentOS7服务器端运行出现lost connection错误 (base) F:\workspace>dir 驱动器 F 中的卷是 新加卷 卷的序列号是 C2B9-62 ...

  3. Flask 邮件发送

    欢迎关注小婷儿的博客: csdn:https://blog.csdn.net/u010986753 博客园:http://www.cnblogs.com/xxtalhr/ 有问题请在博客下留言或加QQ ...

  4. 安装ubuntu系统 ——分区

    安装ubuntu 系统主要分四个区 目录 建议大小 格式 描述 / 10G-20G ext4 根目录 swap <2048M swap 交换空间 /boot 400M左右 ext4 Linux的 ...

  5. 通过cgroup给docker的CPU和内存资源做限制

    1.cpu docker run -it --cpu-period=100000 --cpu-quota=2000 ubuntu /bin/bash 相当于只能使用20%的CPU 在每个100ms的时 ...

  6. day45

    今日内容 1.css三种引入方式 2.三种引入方式的优先级 3.长度及颜色单位 4.常用样式 5.css选择器 CSS三种引入方式 1.1css引入方式之行间式 ​ 行间式(特点): ​ 1.标签头部 ...

  7. c++ 模板参数做容器参数迭代器报错 vector<T>::const_iterator,typename const报错

    错误1: template<class T>void temp(std::vector<T>& container){        std::vector<T& ...

  8. maven使用出现的错误

    修改mvn archetype:create  改成mvn archetype:generate 刚开始学习用Maven, 装好了以后生成一个新的project mvnarchetype:genera ...

  9. Android应用安全之第三方SDK安全

    第三方sdk的包括广告.支付.统计.社交.推送,地图等类别,是广告商.支付公司.社交.推送平台,地图服务商等第三方服务公司为了便于应用开发人员使用其提供的服务而开发的工具包,封装了一些复杂的逻辑实现以 ...

  10. 20155304《网络对抗》Exp4 恶意代码分析

    20155304<网络对抗>Exp4 恶意代码分析 实践内容 1.系统运行监控 1.1使用schtasks指令监控系统运行 我们在C盘根目录下建立一个netstatlog.bat的文本文件 ...