UVA 11136 Hoax or what——multiset

网友投稿 456 2022-11-28

UVA 11136 Hoax or what——multiset

UVA 11136 Hoax or what——multiset

#include #include #include #include #include using namespace std;int main() { int n, k, x; while (~scanf("%d", &n) && n) { long long ans = 0; multiset s; for (int i = 0; i < n; i++) { scanf("%d", &k); for (int j = 0; j < k; j++) { scanf("%d", &x); s.insert(x); } multiset::iterator it1, it2; it1 = s.begin(); it2 = --s.end(); ans = ans + (*it2) - (*it1); s.erase(it1); s.erase(it2); } cout << ans << endl; } return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:UVA 11461 Square Numbers——前缀和水题
下一篇:POJ 3268 Silver Cow Party——dijkstra
相关文章

 发表评论

暂时没有评论,来抢沙发吧~