/*
بسم الله الرحمن الرحيم
Author:
(:Muhammad Aneeq:)
*/
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ld long double
int const N=1e5+10;
ld a[N],b[N];
bool comp(ld i,ld j)
{
return (i>j);
}
inline void solve()
{
int n;
cin>>n;
for (int i=0;i<n;i++)
cin>>a[i]>>b[i];
sort(a,a+n,comp);
sort(b,b+n,comp);
vector<vector<ld>>pre(2,vector<ld>(n+1));
for (int i=0;i<n;i++)
{
pre[0][i+1]=pre[0][i]+a[i];
pre[1][i+1]=pre[1][i]+b[i];
}
ld ans=0;
for (int i=1;i<=2*n;i++)
{
int x=min(n,i);
for (int j=0;j<=x;j++)
ans=max(ans,min(pre[0][j]-i,pre[1][x-j]-i));
}
printf("%.4lf\n",(double)ans);
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2400 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2400 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2400 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |