ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1788. On the Benefits of Umbrellas

Mistake, but.. Where?
Posted by [MAI] Zhigireva Alex 28 Aug 2011 00:29
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool cmp(int a, int b){
return a > b;
}

int main(){
int g, b;
cin >> g >> b;

if (g == b) {
cout << 0 << endl;
return 0;
}

vector<int> girls(g), boys(b);
for (int i=0;i<g;++i){
cin >> girls[i];
}
for (int i=0;i<b;++i){
cin >> boys[i];
}
sort(girls.begin(), girls.end(), cmp);
sort(boys.begin(), boys.end(), cmp);

for (int i=g-2;i>=0;--i){
girls[i]+=girls[i+1];
}
for (int i=b-2;i>=0;--i){
boys[i]+=boys[i+1];
}

vector<int> v(min(g, b));
for (int i=0;i<min(g, b);++i){
v[i] = boys[i]*i + girls[i];
}

int min = v[0];

for (int i=1;i<v.size();++i){
if (min > v[i]) min = v[i];
}

cout << min << endl;
return 0;
}

I don't know which tests fail my code( and why WA1?