-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.cpp
47 lines (39 loc) · 991 Bytes
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <set>
#include <vector>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <cmath>
#include <climits>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using ll = long long;
using vi = std::vector<int>;
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007;
#define sortcut(x) x.begin(), x.end()
#define printl(x, size) for(int i=0; i<size; i++) cout << x[i] << endl;
int main() {
optimize();
int n; cin >> n;
int cows[n];
for (int i = 0; i < n; i++) {
cin >> cows[i];
}
sort(cows, cows + n);
ll max_money = 0;
ll optimal = 0;
for (int i = 0; i < n; i++) {
ll value = (ll)cows[i]*(n-i);
if (value > max_money) {
max_money = value;
optimal = cows[i];
}
}
cout << max_money << " " << optimal << endl;
}