poj 3253
来源:互联网 发布:人生 不 快乐 知乎 编辑:程序博客网 时间:2024/06/08 17:52
贪心。
#include<iostream>#include<algorithm>#include<queue>#define MAXN 20010using namespace std;typedef long long LL;int n,l[MAXN];void solve(){LL ans=0;priority_queue<int,vector<int>,greater<int> >que;while(que.size()>0)que.pop();for(int i=0;i<n;i++)que.push(l[i]);while(que.size()>1){int l1,l2;l1=que.top();que.pop();l2=que.top();que.pop();ans+=l1+l2;que.push(l1+l2);}printf("%lld\n",ans);}int main(){while(~scanf("%d",&n)){for(int i=0;i<n;i++)scanf("%d",&l[i]);solve();}return 0;}
阅读全文
0 0
- POJ 3253
- poj 3253
- poj 3253
- poj 3253
- poj----3253
- poj.3253
- poj 3253
- POJ 3253
- poj 3253
- poj-3253
- POJ-3253
- POJ 3253
- poj 3253
- poj-3253
- poj-3253
- POJ 3253
- POJ 3253
- POJ 3253
- 孙鑫VC++学习:对话框-ONE
- 设计模式之观察者模式
- class, extends, super
- Spring Cloud构建微服务架构(五)服务网关
- dict语法 --鱼c工作室笔记
- poj 3253
- 高通平台中简单了解DTB
- 【人工智能】图像识别之小白天书——验证码篇(3)
- ARP协议【地址解析协议】
- ELK 日志分析系统(二)
- php 处理文件
- WIN10使用 NetSpeedMonitor
- Linux select服务器
- [LeetCode-6]ZigZag字符串的变换输出