#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
long long N; cin >> N;
vector<long long> bal(N, 0);
long long sum = 0;
for (long long i = 0; i < N; i++) {
cin >> bal[i];
sum += bal[i];
}
sort(bal.begin(), bal.end());
reverse(bal.begin(), bal.end());
vector<long long> pref(N, 0);
pref[0] = bal[0];
for (long long i = 1; i < N; i++) {
pref[i] = pref[i - 1] + bal[i];
}
double diff = 0;
double A, B;
double final_A;
double final_B;
for (long long i = 0; i < N; i++) {
A = (double) (i + 1) / N * 100;
B = (double) pref[i] / sum * 100;
if (B - A > diff) {
final_A = A;
final_B = B;
}
diff = B - A;
}
cout << final_A << endl;
cout << final_B << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
4 ms |
440 KB |
Output is correct |
6 |
Correct |
38 ms |
2072 KB |
Output is correct |
7 |
Correct |
77 ms |
3584 KB |
Output is correct |
8 |
Correct |
91 ms |
5140 KB |
Output is correct |