|
|
вернуться в форумMistake, but.. Where? #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? |
|
|