#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lb long double
int main()
{
ll n;
lb sum=0;
cin>>n;
lb arr[n];
for(ll i=0; i<n; i++)
{
cin>>arr[i];
sum+=arr[i];
}
sort(arr, arr+n);
reverse(arr, arr+n);
lb cursum=0;
lb a=100.0, b=100.0;
for(ll i=0; i<n; i++)
{
cursum+=arr[i];
lb aa = (i+1)*100/(lb)n;
lb bb = (cursum*100)/sum;
if((bb-aa)>(b-a))
{
a=aa;
b=bb;
}
//cout<<a <<" " <<b <<"\n";
}
cout<<a <<"\n";
cout<<b <<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
7 ms |
532 KB |
Output is correct |
6 |
Correct |
61 ms |
2228 KB |
Output is correct |
7 |
Correct |
127 ms |
4648 KB |
Output is correct |
8 |
Correct |
163 ms |
6568 KB |
Output is correct |