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 <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
#define in cin
#define out cout
#define _abs(a) ((a)>0?(a):(-(a)))
#define _min(a,b) ((a)>(b)?(b):(a))
#define _max(a,b) ((a)<(b)?(b):(a))
#define isin(a,b,c) ((a)<=(c)&&(c)<=(b))
#define REP(i,e) for(int i=0; i<e; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define X first
#define Y second
#define pdd pair<double, double>
int main()
{
int n; in >> n; if(n > 1000) return 0;
vector< pdd > o(n), v(n);
REP(i,n) in >> v[i].Y;
REP(i,n) in >> v[i].X;
REP(i,n) o[i] = v[i];
sort(v.begin(), v.end());
double sum = 0.0;
REP(i,n) sum += v[i].Y;
double mint = 111111111111.0;
int mina, minb;
REP(i,v.size())
{
REP2(j,i+1,v.size())
{
double k = v[i].X;
double m = v[i].Y;
double t = (k - (k*k)/(k+v[j].X))*(sum-m-v[j].Y);
if(mint > t)
{
mint = t;
mina = i, minb = j;
}
}
}
int ra, rb;
REP(i,n)
{
if(v[mina] == o[i]) ra = i;
if(v[minb] == o[i]) rb = i;
} ra++; rb++;
if(ra > rb)
out << rb << " " << ra << endl;
else
out << ra << " " << rb << endl;
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... |