Submission #596234

#TimeUsernameProblemLanguageResultExecution timeMemory
596234hailPareto (COCI17_pareto)C++17
80 / 80
45 ms4160 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<ll> money_arr(n); cout<<setprecision(20); long long total_money{}; for(int i=0; i<n; i++) { cin>>money_arr[i]; total_money+=money_arr[i]; } double perc_ppl; double perc_money; double ppl; double money; double max_d{}; double money_sum{}; sort(money_arr.rbegin(), money_arr.rend()); for(int i=1; i<=n; i++) { money_sum+=money_arr[i-1]; perc_ppl = (i/((double)n)); perc_money = money_sum/((double)total_money); if(abs(perc_money-perc_ppl)>max_d) { max_d = abs(perc_money-perc_ppl); money = perc_money; ppl = perc_ppl; } } cout<<(ppl*100)<<"\n"<<(money*100); }

Compilation message (stderr)

pareto.cpp: In function 'int main()':
pareto.cpp:53:38: warning: 'money' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |     cout<<(ppl*100)<<"\n"<<(money*100);
      |                                      ^
pareto.cpp:53:19: warning: 'ppl' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |     cout<<(ppl*100)<<"\n"<<(money*100);
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...