Skip to content

Instantly share code, notes, and snippets.

@garvitlnmiit
Last active June 18, 2017 04:47
Show Gist options
  • Save garvitlnmiit/7c54ba4ebde3f6e6cfa06c70bcddaee7 to your computer and use it in GitHub Desktop.
Save garvitlnmiit/7c54ba4ebde3f6e6cfa06c70bcddaee7 to your computer and use it in GitHub Desktop.
Codechef ZCO14003 Solution
// Garvit Sharma <garvits45@gmail.com> <garvitlnmiit> <garvitsharma.in>
// Codechef ZCO, problem 1
#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 500000;
typedef long long ll;
ll data[MAX_SIZE];
int main() {
int n;
ll maxProfit=0;
scanf("%d",&n);
for(int i=0; i<n; i++) {
scanf("%lld",data+i);
}
sort(data, data+n);
for(int i=0; i<n; i++) {
maxProfit=max(maxProfit, (n-i)*data[i]);
}
cout << maxProfit << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment