This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
int n;
long long int a[1009];
long long int b[1009];
long long int x;
int main()
{
scanf("%d",&n);
if(n>1000)printf("3 8\n");
int i, j, k;
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
x += a[i];
}
for(i=0;i<n;i++)
scanf("%lld",&b[i]);
long long int p,q,r,s;
int mi,mj;
mi=mj=-1;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
r=(x-a[i]-a[j])*b[i]*b[j];
s=(b[i]+b[j]);
if(mi==-1)
{
p = r;
q = s;
mi = i;
mj = j;
}
else
{
if(p/q > r/s)
{
p = r;
q = s;
mi = i;mj = j;
}
else if(p/q<r/s) continue;
long long int t,u;
t = p%q;
u = r%s;
if(t*s > r*u)
{
p = r;
q = s;
mi = i;mj = j;
}
}
}
printf("%d %d\n",mi+1,mj+1);
}
# | 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... |