이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ld> vi;
typedef pair<ld,ld> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 101010
vector<ld> A,B;
ld a,b;
int N;
bool work(ld v){
ld x = v;
ld y = v;
int a = 0;
int b = 0;
while(x > 0 || y > 0){
++x;++y;
if (x > 0){
if (a==SZ(A))return 0;
x -= A[a];
++a;
}else if (y > 0){
if (b==SZ(B))return 0;
y -= B[b];
++b;
}
}
return 1;
}
int main(){
cin>>N;
for (int i=1;i<=N;++i){
cin>>a>>b;
if (a>1)A.pb(a);
if (b>1)B.pb(b);
}
sort(ALL(A));reverse(ALL(A));
sort(ALL(B));reverse(ALL(B));
ld ub=100000000;
ld lb=0;
while (ub>lb+0.000001){
ld mid=(lb+ub)/2;
if (work(mid))lb = mid;
else ub = mid;
}
lb *= 10000;
lb = roundf(lb);
printf("%.4lf",(double)(lb/10000));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |