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<cstdio>
#include<algorithm>
using namespace std;
long long n,mh,cnt,s,a1,a2,c[100005];
double mn=10000000000000000000,t;
struct Data{
long long h,t,idx;
bool operator ()(Data q,Data w){
if(q.h>w.h)return true;
return false;
}
}d[100005],r[100005];
int main()
{
int i,j;
scanf("%d",&n);
for(i=0;i<n;s+=d[i++].h)
scanf("%d",&d[i].h);
for(i=0;i<n;d[i++].idx=i)
scanf("%d",&d[i].t);
sort(d,d+n,Data());
for(i=0;i<n;i++) {
if(c[d[i].h]<2){
c[d[i].h]++;
r[cnt++]=d[i];
}
}
for(i=0;i<cnt;i++){
for(j=i+1;j<cnt;j++) {
t=(double)(s-r[i].h-r[j].h)/((double)1/r[i].t+(double)1/r[j].t);
if(t<mn){
mn=t;
a1=r[i].idx+1;
a2=r[j].idx+1;
}
}
}
printf("%lld %lld",a1,a2);
}
# | 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... |