Maximum number of objects that can be created as per given conditions | C ++ program for the above problem ; Function for finding the maximum number of objects from N type - 1 and M type - 2 items ; storing minimum of N and M ; storing maximum number of objects from given items ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int numberOfObjects ( int N , int M ) { int initial = min ( N , M ) ; int final = ( N + M ) / 3 ; return min ( initial , final ) ; } int main ( ) { int N = 8 ; int M = 7 ; cout << numberOfObjects ( N , M ) << endl ; return 0 ; }