居然和BZOJ 1724完全一样o(╯□╰)o

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int n;
priority_queue<int,vector<int>,greater<int> > q; inline int read()
{
char ch;
int num,f=;
while(!isdigit(ch=getchar())) f|=(num=='-');
num=ch-'';
while(isdigit(ch=getchar())) num=num*+ch-'';
return f?-num:num;
} int main()
{
n=read();
for(int i=;i<=n;i++)
{
int x=read();
q.push(x);
} if(n==){cout << q.top();return ;} ll res=;
while(q.size()>)
{
int x=q.top();q.pop();
int y=q.top();q.pop();
res+=(x+y);
q.push(x+y);
}
cout << res;
return ;
}

最新文章

  1. libuv源码分析前言
  2. bluetooth service uuid
  3. Android课程---Android Studio的一些小技巧
  4. 数往知来 asp.net 聊天室问题解决方案&lt;十六&gt;
  5. Yum本地Rpm库设置
  6. scala函数进阶与lazy的作用
  7. ABP入门系列(16)——通过webapi与系统进行交互
  8. spring-线程池(3)
  9. Flask 蓝图(Blueprint)
  10. NIOS II 之串口学习
  11. Python—字符串的操作
  12. llvm Array Bounds Check Elimination
  13. linux 内核移植
  14. Android adb 命令速查表
  15. BZOJ4897: [Thu Summer Camp2016]成绩单【DP of DP】
  16. pycharm字体放大缩小设置
  17. (转)USB的描述符及各种描述符之间的依赖关系
  18. php -- 四种基础排序:冒泡、选择、插入、快速
  19. LCS(最长公共子序列)动规算法正确性证明
  20. 【BZOJ】1588: [HNOI2002]营业额统计

热门文章

  1. Vuejs - 强大的指令系统
  2. Spring与MyBatis的整合(山东数漫江湖)
  3. 表格td内容超出宽度显示... table-layout: fixed;
  4. 工具_HBuilder使用快捷方式
  5. windows7_常用操作终端操作
  6. eureka服务端
  7. 64_g3
  8. 阿波罗11号登月飞船电脑控制系统源码(AGC)
  9. selenium遇到的一些问题,持续更新
  10. 使用JMX工具远程监控tomcat配置