HDU 4974 A simple water problem 模拟(水
来源:互联网 发布:尉迟琳嘉 知乎 编辑:程序博客网 时间:2024/05/20 18:50
水题。
#include <cstdio>#include <iostream>#include <queue>#include <algorithm>using namespace std;typedef long long ll;priority_queue<int> q;int main() { int T, cas = 0; scanf("%d", &T); while(T-- > 0) { int n; scanf("%d", &n); for(int i = 0, x; i < n; i ++) { scanf("%d", &x); q.push(x); } ll ans = 0; while(!q.empty()) { if(q.size() >= 2) { int x = q.top(); q.pop(); int y = q.top(); q.pop();// printf("%d %d\n", x, y); ans += y; q.push(x-y); } else { ans += q.top(); q.pop(); } } printf("Case #%d: ", ++cas); cout << ans << endl; } return 0;}
0 0
- HDU 4974 A simple water problem 模拟(水
- HDU - 4974 A simple water problem
- HDU 4974 A simple water problem(贪心)
- hdu 4974 A simple water problem(水题)
- HDU - 4974 A simple water problem
- HDU 4974 A simple water problem
- hdu 4974 A simple water problem(数学题)
- hdu - 4974 - A simple water problem(贪心 + 反证)
- hdu - 4974 - A simple water problem(贪心 + 反证)
- hdu 4974——A simple water problem
- HDU 4967 A simple water problem
- A simple water problem
- 【杂题】 HDOJ 4974 A simple water problem
- HDOJ 4974 A simple water problem
- HDU 5832A water problem 简单模拟
- hdu 2522 A simple problem(模拟)
- HDU4974:A simple water problem
- HDU4974 A simple water problem
- JSP自定义标签开发(五)——标签类获取 request 、 session
- 分布式服务框架 Zookeeper -- 管理分布式环境中的数据
- 块元素与行内元素
- android中ListView的setItemChecked方法
- Struts框架如何取得消息资源文件中的信息?
- HDU 4974 A simple water problem 模拟(水
- hdoj 2093 考试排名
- 回调函数的分析及应用
- iOS测试——置换测试: Mock, Stub 和其他
- Windows调试的基石——符号(1)
- Zookeeper
- HDU 4975 A simple Gaussian elimination problem. 网络流+矩阵上的dp
- 【Qt编程】基于Qt的词典开发系列<十五>html特殊字符及正则表达式
- 链表增删改查