#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector <int> v(n);
long long sum = 0;
for(int i = 0; i < n; i++){
cin >> v[i];
sum += v[i];
}
sort(v.rbegin(), v.rend());
long long curr = 0;
double a, b;
double solb = 0.0, sola = 0.0;
for(int i = 0; i < n; i++){
curr += v[i];
a = (double) (i+1) / n;
b = (double) curr / sum;
if(b - a > solb - sola){
solb = b, sola = a;
}
}
cout << fixed << setprecision(14) << sola * 100 << "\n";
cout << fixed << setprecision(14) << solb * 100;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
392 KB |
Output is correct |
4 |
Correct |
2 ms |
436 KB |
Output is correct |
5 |
Correct |
6 ms |
468 KB |
Output is correct |
6 |
Correct |
45 ms |
984 KB |
Output is correct |
7 |
Correct |
109 ms |
1244 KB |
Output is correct |
8 |
Correct |
128 ms |
1636 KB |
Output is correct |