Submission #136919

# Submission time Handle Problem Language Result Execution time Memory
136919 2019-07-26T14:15:02 Z dnass Pareto (COCI17_pareto) C++14
80 / 80
166 ms 4204 KB
#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

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 time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 9 ms 504 KB Output is correct
6 Correct 54 ms 1528 KB Output is correct
7 Correct 124 ms 3112 KB Output is correct
8 Correct 166 ms 4204 KB Output is correct