Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
My solution for UVA 11136
#include <iostream>
#include <set>
using namespace std;
int n, x, k;
long long sum;
multiset<int> bills;
int main() {
while(cin >> n, n) {
sum = 0;
for(int nn=0; nn<n; nn++) {
cin >> k;
for(int i=0; i<k; i++) {
cin >> x;
auto hit = bills.end(), lot = bills.begin(); hit--;
sum += (*hit)-(*lot);
bills.erase(hit); bills.erase(lot);
cout << sum << '\n';
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.