HDU 4974 A simple water problem 模拟(水
2014-08-21 17:51
323 查看
水题。
#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; }
相关文章推荐
- hdu - 4974 - A simple water problem(贪心 + 反证)
- hdu 4974 A simple water problem
- hdu 4974 A simple water problem(多校第十场 水题)
- 2014多校第十场1004 || 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 4974 A simple water problem(14多校8)思维题
- hdu 4974——A simple water problem
- HDOJ 4974 A simple water problem
- hdu_5832_A water problem(模拟)
- HDOJ 4974 A simple water problem
- 【杂题】 HDOJ 4974 A simple water problem
- A - A water problem HDU - 5832(模拟除法)