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

#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. javascript 正则表达式的使用

    1. 语法 有两种定义正则表达式的方式 字面量形式 var expression = /pattern/flags 引用 MDN 的解释: pattern:正则表达式的文本. flags:标志,可以是 ...

  2. centos中,tomcat项目创建文件的权限

    参考文章:https://cloud.tencent.com/info/5f02caa932fd6dbfc46a3bb01af135e0.html 我们在centos中输入umask,会看到输出002 ...

  3. 【11】python 递归,深度优先搜索与广度优先搜索算法模拟实现

    一.递归原理小案例分析 (1)# 概述 递归:即一个函数调用了自身,即实现了递归 凡是循环能做到的事,递归一般都能做到! (2)# 写递归的过程 1.写出临界条件 2.找出这一次和上一次关系 3.假设 ...

  4. C++第六次作业

    前言 拿到作业的时候,整个人都不好了,虽然之前和同学说以后一起写游戏,画界面,然而现在的自己对界面的知识一窍不通,虽然同学分享了一些资料,但是通过这次作业,发现自己火候还是不够-- 问题描述及仓库地址 ...

  5. js节流

    function _throttling(fn,wait,mustRun){ var time=null; var startTime= new Date() return function(){ c ...

  6. 经实测解决Access-Control-Allow-Origin多域名跨域问题

    网上流传2种方法解决多域名跨域问题:1.Access-Control-Allow-Origin:[域名一],[域名二]: 2.用$_SERVER("HTTP_ORIGIN")获取来 ...

  7. 记一次MyBatis的错误

    错误信息:java.lang.StackOverflowError 关于这个错误的深度解析,大家可以参考这篇博文,比较详细:https://blog.csdn.net/zc375039901/arti ...

  8. JS 仿腾讯发表微博的效果

    JS 仿腾讯发表微博的效果 最近2天研究了下 腾讯发表微博的效果 特此来分享下,效果如下: 在此分享前 来谈谈本人编写代码的习惯,很多人会问我既然用的是jquery框架 为什么写的组件不用Jquery ...

  9. Android 多用户多缓存的简单处理方案

    需求:1.在缓存中记录用户登录信息.例如:用户名,密码 2.记录用户操作数据.例如:是否记住用户名密码.设置7天内自动登录等 简单设计:1)使用sqlite设计一张用户数据表,有用户名.密码.操作数据 ...

  10. 随机取出数组中的某些值,并删除它们array_splice,array_slice

    今天遇到这样一个情景.这样的,一个抽奖活动,预先获取一堆人参与信息,一个人最多只能中奖一次.活动有活动的配置信息,比如说一等奖有多少人,二等奖有多少人等等.. 说白了,就是从这个参与人数组里,取出来一 ...