CSAca Choose the Price
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
#define mset(c,v) memset(c , v , sizeof c)
#define loop0(n) for(int i=0; i<n; i++)
#define loop1(n) for(int i=1; i<=n; i++)
#define mpair(x , y) make_pair(x , y)
#define all(x) x.begin(), x.end()
#define pi acos(-1.0)
#define psb push_back
typedef unsigned long long ull;
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef vector<string>vs;
typedef map<int, int>mpii;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;
typedef map<LL, LL>mpll;
const int mod = 1000007;
const int high = 1002;
vll v;
int main()
{
fast;
int i , N , x;
while(cin >> N)
{
v.clear();
for(i=0; i<N; i++)
{
cin >> x;
v.push_back(x);
}
sort(v.rbegin() , v.rend()); // as i have to increase my income, so i sorted amounts a descending order.
LL mx = 0;
for(i=0; i<N; i++)
{
LL price = (i + 1) * v[i];
mx = max(mx , price); // pick the maximum
}
outn(mx);
}
return 0;
}
using namespace std;
#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
#define mset(c,v) memset(c , v , sizeof c)
#define loop0(n) for(int i=0; i<n; i++)
#define loop1(n) for(int i=1; i<=n; i++)
#define mpair(x , y) make_pair(x , y)
#define all(x) x.begin(), x.end()
#define pi acos(-1.0)
#define psb push_back
typedef unsigned long long ull;
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef vector<string>vs;
typedef map<int, int>mpii;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;
typedef map<LL, LL>mpll;
const int mod = 1000007;
const int high = 1002;
vll v;
int main()
{
fast;
int i , N , x;
while(cin >> N)
{
v.clear();
for(i=0; i<N; i++)
{
cin >> x;
v.push_back(x);
}
sort(v.rbegin() , v.rend()); // as i have to increase my income, so i sorted amounts a descending order.
LL mx = 0;
for(i=0; i<N; i++)
{
LL price = (i + 1) * v[i];
mx = max(mx , price); // pick the maximum
}
outn(mx);
}
return 0;
}
Comments
Post a Comment