이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,p1,p2;
long long sum,h[100010],t[100010];
double st=0,en,mid;
int pro(double v){
int i,s;
double maxi1=0,maxi2=0;
for(i=1;i<=n;i++){
s=h[i]+v/t[i];
if(maxi1<s) maxi1=s, p1=i;
}
for(i=1;i<=n;i++){
s=h[i]+v/t[i];
if(maxi2<s && p1!=i) maxi2=s, p2=i;
}
if(maxi1+maxi2>=sum) return 1;
return 0;
}
int main()
{
int i,c=0;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%lld",&h[i]), sum+=h[i];
for(i=1;i<=n;i++) scanf("%lld",&t[i]);
en=double(sum-h[1]-h[2])/(1.0/t[1]+1.0/t[2])+100;
while(en-st>1e-5){
c++;
if(c==200) break;
mid=(st+en)/2.0;
if(pro(mid)==1) en=mid;
else st=mid;
}
printf("%d %d",min(p1,p2),max(p1,p2));
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |