이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// author : aykhn
using namespace std;
typedef long long ll;
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define bpcll __builtin_popcountll
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
void _()
{
int n;
cin >> n;
double a[n], b[n];
double res = 0;
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
sort(a, a + n, greater<double> ());
sort(b, b + n, greater<double> ());
int i = 0;
int j = 0;
double sum1 = 0, sum2 = 0;
while (i < n || j < n)
{
if (i == n) sum2 += b[j++];
else if (j == n) sum1 += a[i++];
else if (sum1 + a[i] <= sum2 + b[j]) sum1 += a[i++];
else sum2 += b[j++];
res = max(res, min(sum2, sum1) - i - j);
}
cout.precision(4);
cout << fixed << res << '\n';
}
signed main()
{
int t = 1;
// cin >> t;
for (int tt = 0; tt < t; tt++)
{
_();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |