이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#define int int64_t
using namespace std;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<double> a(n);
vector<double> b(n);
for (int i = 0; i < n; i++)
{
cin >> a[i] >> b[i];
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
int ac = 0;
int bc = 0;
double glmax = 0;
double curra = 0;
double currb = 0;
while (ac + bc < 2*n)
{
curra -= 1;
currb -= 1;
if (ac == n || currb < curra)
{
currb += b[bc];
bc++;
}
else
{
curra += a[ac];
ac++;
}
glmax = max(glmax, min(curra, currb));
}
printf("%.4lf",(double)glmax);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |