이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#define double double
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
using namespace std;
vector<double>sum(2);
vector<int>sum2(2);
signed main()
{
int n;
cin>>n;
vector<double>a(n),b(n);
rep(i,n) cin>>a[i]>>b[i];
sort(all(a));
sort(all(b));
reverse(all(a));
reverse(all(b));
for(int i = 1; i<n; i++)
{
a[i]+=a[i-1];
b[i]+=b[i-1];
}
double maxx = 0;
rep(i,n)
{
auto it = lower_bound(b.begin(), b.end(), a[i]);
if(it==b.end()) continue;
int j = it - b.begin();
double val = min(a[i], b[j]) - i - j - 2;
maxx=max(maxx, val);
}
rep(i,n)
{
auto it = lower_bound(a.begin(), a.end(), b[i]);
if(it==a.end()) continue;
int j = it - a.begin();
double val = min(b[i], a[j]) - i - j - 2;
maxx=max(maxx, val);
}
//cout<<(int)maxx<<".";
//maxx-=(int)maxx;
//rep(i,3)
//{
// maxx*=10;*lower_bound)
// cout<<(int)maxx;
// maxx-=(int)maxx;
//}
//maxx*=10;
//int o = (int)maxx;
//if(1000*o+499<1000*maxx) o++;
//cout<<o;
printf("%.4lf",(double)maxx);
//cout<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |