이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
double a[N], b[N];
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i];
a[i] -= 1.0;
b[i] -= 1.0;
}
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
sort(b + 1, b + n + 1);
reverse(b + 1, b + n + 1);
int j = 1; double sa = 0, sb = 0, ans = 0, now;
for (int i = 1; i <= n; i++)
{
sa += a[i];
sb -= 1.0;
now = min(sa, sb);
ans = max(ans, now);
int jj = j;
while (jj <= n)
{
if (min(sa - 1.0, sb + b[jj]) > now)
{
sa -= 1.0;
sb += b[jj];
now = min(sa, sb);
jj++;
}
else
break;
}
ans = max(ans, now);
j = jj;
}
cout << fixed << setprecision(4) << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |