Submission #599508

#TimeUsernameProblemLanguageResultExecution timeMemory
599508DrollWolfPareto (COCI17_pareto)C++17
80 / 80
146 ms4216 KiB
#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)

pareto.cpp: In function 'int main()':
pareto.cpp:11:12: warning: variable 'k' set but not used [-Wunused-but-set-variable]
   11 |  lli n, i, k;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...