比赛 20160419s 评测结果 AAAAAAAAAA
题目名称 扑克游戏 最终得分 100
用户昵称 mikumikumi 运行时间 0.020 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2016-04-19 11:06:03
显示代码纯文本
  1. #include<cstdio>
  2. #include<queue>
  3. #include<iostream>
  4. using namespace std;
  5. const int SIZEN=10010;
  6. priority_queue<int,vector<int>,greater<int> > Q;
  7. int N;
  8. void read()
  9. {
  10. scanf("%d",&N);
  11. int a;
  12. for(int i=1;i<=N;i++)
  13. {
  14. scanf("%d",&a);
  15. Q.push(a);
  16. }
  17. }
  18. void work()
  19. {
  20. int ans=0;
  21. while(Q.size()>1)
  22. {
  23. int x=Q.top();Q.pop();
  24. int y=Q.top();Q.pop();
  25. int tem=x+y;
  26. ans+=tem;
  27. Q.push(tem);
  28. }
  29. printf("%d\n",ans);
  30. }
  31. int main()
  32. {
  33. freopen("poker.in","r",stdin);
  34. freopen("poker.out","w",stdout);
  35. read();
  36. work();
  37. return 0;
  38. }