Submission #136919

#TimeUsernameProblemLanguageResultExecution timeMemory
136919dnassPareto (COCI17_pareto)C++14
80 / 80
166 ms4204 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int lld; lld n; lld a[300100]; int main(){ cout.precision(15); cin >> n; lld tot_sum = 0; for(lld i=0;i<n;i++){ cin >> a[i]; tot_sum += a[i]; } sort(a, a+n); reverse(a, a+n); lld sum = 0; double max_dif = -1; double aa, bb, real_a, real_b; for(lld i=0;i<n;i++){ sum += a[i]; aa = ((double)(i+1))/((double)n); bb = ((double)sum)/((double)tot_sum); if(bb-aa>max_dif){ max_dif = bb-aa; real_b = bb; real_a = aa; } } cout << 100*real_a << endl; cout << 100*real_b << endl; return 0; }

Compilation message (stderr)

pareto.cpp: In function 'int main()':
pareto.cpp:32:14: warning: 'real_b' may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << 100*real_b << endl;
              ^~~~~~
pareto.cpp:31:14: warning: 'real_a' may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << 100*real_a << endl;
              ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...