ZCO14003

 avatar
unknown
c_cpp
3 years ago
751 B
2
Indexable
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>

using namespace std;
int main()
{
    int t;
    cin>>t;
    int b[t];
    
    int max_rev=0;
    //enter the budgets
    int i;
    for(i=0;i<t;i++)
    {
        cin>>b[i];
    }
    //budgets stored in the array
    int p; //test variable for price selection
    sort(b,b+t); //array of budgets is sorted in ascending order
    for(p=0;p<=b[t-1];p++) //taking price test var from 0 to max of budgets
    { int count =0;
        for(i=0;i<t;i++)
        {
            if (p<=b[i])
            count++;
        }
       int  rev=p*count;
        max_rev=max(max_rev,rev);

    }
    cout<<"the maximum revenue is -"<< max_rev<<endl;


    return 0;
}