UVA - 11136 Hoax or what

来源:互联网 发布:js获取div下的span 编辑:程序博客网 时间:2024/05/16 11:07
#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。。
0 0