Last active
June 18, 2017 04:47
-
-
Save garvitlnmiit/7c54ba4ebde3f6e6cfa06c70bcddaee7 to your computer and use it in GitHub Desktop.
Codechef ZCO14003 Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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