답안 #599508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599508 2022-07-19T14:52:52 Z DrollWolf Pareto (COCI17_pareto) C++17
80 / 80
146 ms 4216 KB
#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

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;
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
6 Correct 47 ms 1560 KB Output is correct
7 Correct 102 ms 3068 KB Output is correct
8 Correct 146 ms 4216 KB Output is correct