There is m men, and n women.The boss chooses k people. Them divide m+n-k remain people into t groups, each group exactly 2 men and 1 woman. Find max(t)
For example:
Input
264936043 821529140 438045170
Ouput
132468021
#include <iostream>
using namespace std;
int n, m, k, res, t;
int main(){
cin >> n >> m >> k;
for (int i = max(k-m, 0); i <= n; i++){
res = max(res, min((n-i)/2, m-k+i));
}
cout << res;
}
My code is TLE.
I think the number of men chosen is (n+2k-2m)/3 because (n-i) ~ 2*(m-k+i), but it is not correct.
Aucun commentaire:
Enregistrer un commentaire