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

#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. vc MFC 通过IDispatch调用默认成员函数

    CComPtr<IDispatch> spDisp(IDispatch *); if(!spDisp) return; DISPPARAMS dispParam={0}; //没有参数 V ...

  2. Local policy - User rights assignment 对照表

    "SeCreateTokenPrivilege"  --> "Create a token object" "SeAssignPrimaryTo ...

  3. openlayer3 基础学习一创建&显示地图

    <!doctype html> <html lang="en"> <head> <link rel="stylesheet&qu ...

  4. 【转】Fiddler工作原理

    原文章链接:Web代码网chinabit.org Fiddler是一个http调试代理,它能 够记录所有的你电脑和互联网之间的http通讯,Fiddler 可以也可以让你检查所有的http通讯,设置断 ...

  5. 【正则表达式】用js实现千位分隔符,怎么实现?

    (?=pattern)  正向预查,在任何匹配 pattern 的字符串开始处匹配查找字符串.这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用.例如,'Windows (?=95|98|NT| ...

  6. 回调函数ros::spin()与ros::spinOnce()

    ros::spin() 这句话的意思是循环且监听反馈函数(callback).循环就是指程序运行到这里,就会一直在这里循环了.监听反馈函数的意思是,如果这个节点有callback函数,那写一句ros: ...

  7. SpringBoot实用技巧札记

    目录 如何手工设置SpringBoot内嵌的Tomcat启动端口号(port) 如何解决Eclipse.Properties中文乱码的问题 如何手工设置SpringBoot内嵌的Tomcat启动端口号 ...

  8. Python2.7-stat

    stat模块,用于解释 os.stat(),os.lstat(),os.fstat() 返回的结果,定义了许多表示文件或路径的各个状态的常数和测试各个状态的函数具体参考 官方文档 和 http://w ...

  9. web.xml配置遇到的问题

    web.xml<listener>            <listener-class>org.springframework.web.context.ContextLoad ...

  10. Working With JSON

    JavaScript对象表示法(JSON)是用于将结构化数据表示为JavaScript对象的标准格式,通常用于在网站上表示和传输数据(例如从服务器向客户端发送一些数据,因此可以将其显示在网页上). J ...