Submission #599364

# Submission time Handle Problem Language Result Execution time Memory
599364 2022-07-19T13:01:13 Z rajatshenoi Pareto (COCI17_pareto) C++14
30 / 80
105 ms 4136 KB
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	int N; cin >> N;

	vector<int> bal(N, 0);

	int sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> bal[i];
		sum += bal[i];
	}

	sort(bal.begin(), bal.end(), greater<int>());

	vector<int> pref(N, 0);

	pref[0] = bal[0];

	for (int i = 1; i < N; i++) {
		pref[i] = pref[i - 1] + bal[i];
	}

	float diff = 0;
	float A, B;
	float final_A;
	float final_B;
	for (int i = 0; i < N; i++) {
		A = (float) (i + 1) / N * 100;
		B = (float) pref[i] / sum * 100;

		if (abs(B - A) > diff) {
			final_A = A;
			final_B = B;
		}

		diff = abs(B - A);
	}

	cout << final_A << endl;
	cout << final_B << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 308 KB Output isn't correct
5 Incorrect 4 ms 340 KB Output isn't correct
6 Incorrect 30 ms 1556 KB Output isn't correct
7 Incorrect 70 ms 2992 KB Output isn't correct
8 Incorrect 105 ms 4136 KB Output isn't correct