# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
597468 | zeroesandones | Pareto (COCI17_pareto) | C++17 | 44 ms | 3000 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb push_back
void solve()
{
int n;
cin >> n;
int a[n];
double total = 0;
FOR(i, 0, n) {
cin >> a[i];
total += a[i];
}
cout << fixed << setprecision(15);
double sum = 0;
pair<double, double> ans = {0.0, 0.0};
sort(a, a+n, greater<int>());
FOR(i, 0, n) {
sum += a[i];
double money = (sum / total);
double people = ((double) (i + 1)) / ((double) (n));
if(money - people > ans.sc - ans.fr)
ans = {people, money};
}
cout << ans.fr * 100 << nl << ans.sc * 100<< nl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |