/* Ajay Jadhav */
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <string.h>
#include <climits>
#include <cstring>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define all(a) (a).begin(),(a).end()
#define x first
#define y second
#define sz(x) (int)x.size()
#define hell 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
void solve()
{
int n;
cin>>n;
double total_money = 0;
vector<double> a(n);
rep(i,0,n)
{
cin>>a[i];
total_money += a[i];
}
double dif = 0;
double A, B;
double sum_money = 0;
double accounts = 0;
double per_money = 0;
double per_accounts = 0;
sort(all(a));
for (int i = n - 1; i >= 0; i--)
{
sum_money += a[i];
accounts++;
per_money = (sum_money / total_money) * 100.0;
per_accounts = (accounts / n) * 100.0;
if (per_money - per_accounts > dif)
{
dif = per_money - per_accounts;
A = per_accounts;
B = per_money;
}
}
cout<<fixed<<setprecision(10)<<A<<endl;
cout<<fixed<<setprecision(10)<<B<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin>>t;
while (t--)
{
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
452 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
4 ms |
600 KB |
Output is correct |
6 |
Correct |
21 ms |
1628 KB |
Output is correct |
7 |
Correct |
43 ms |
3168 KB |
Output is correct |
8 |
Correct |
64 ms |
4200 KB |
Output is correct |