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