您的位置:首页 > 其它

UVA - 11136 Hoax or what

2016-01-26 02:21 393 查看
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
const int maxn = 100000 + 7;
const int INF = ~0U >> 1;
typedef long long LL;
multiset<int> s;
int n, k;

int main() {
while(scanf("%d", &n) != EOF && n) {
s.clear();
int a;
LL sum = 0;
for(int i = 0; i < n; ++i) {
scanf("%d", &k);
for(int j = 0; j < k; ++j) {
scanf("%d", &a);
s.insert(a);
}
multiset<int>::iterator beg = s.begin(), en = s.end();
en--;
sum += (*en - *beg);
s.erase(beg); s.erase(en);
}
printf("%lld\n", sum);
}
return 0;
}
会爆int。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: