# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599508 | DrollWolf | Pareto (COCI17_pareto) | C++17 | 146 ms | 4216 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
//const int N = 2*(10e5+7);
//int arr[N];
int main()
{
lli n, i, k;
double money=0.0, people=0.0, max_dif=0.0, j, temp, sum=0.0;
cin>>n;
double arr[n+1];
arr[0]=0.0;
for(i=1;i<=n;i++)
{
cin>>temp;
sum+=(double)temp;
arr[i]=(double)temp;
}
sort(arr, arr+(n+1));
for(i=1;i<=n;i++)
arr[i]+=arr[i-1];
k=n;
j=1.0;
for(i=n;i>0;i--)
{
double temp_people=(j/(double)n)*100.0;
double temp_money=((arr[n]-arr[i-1])/sum)*100.0;
if(temp_money-temp_people>max_dif)
{
max_dif=temp_money-temp_people;
people=temp_people;
money=temp_money;
}
j++;
}
cout<<people<<'\n';
cout<<money<<'\n';
//freopen("diamond.in","r",stdin);
//freopen("diamond.out","w",stdout);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |