记录编号 | 252138 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 扑克游戏 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.020 s | ||
提交时间 | 2016-04-19 16:16:56 | 内存使用 | 0.31 MiB | ||
#include<cstdio> #include<queue> #include<iostream> using namespace std; const int SIZEN=10010; priority_queue<int,vector<int>,greater<int> > Q; int N; void read() { scanf("%d",&N); int a; for(int i=1;i<=N;i++) { scanf("%d",&a); Q.push(a); } } void work() { int ans=0; while(Q.size()>1) { int x=Q.top();Q.pop(); int y=Q.top();Q.pop(); int tem=x+y; ans+=tem; Q.push(tem); } printf("%d\n",ans); } int main() { freopen("poker.in","r",stdin); freopen("poker.out","w",stdout); read(); work(); return 0; }