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>
#include<utility>
using namespace std;
const int MAX_N = 100100;
pair<double,int> p[MAX_N];
int n,s[MAX_N],t[MAX_N];
long long sum;
void input() {
scanf("%d",&n);
for(int i=0;i<n;i++) {
scanf("%d",&s[i]);
sum += (long long)s[i];
}
for(int i=0;i<n;i++) scanf("%d",&t[i]);
return;
}
bool decision(double x) {
for(int i=0;i<n;i++) {
p[i].first = (double)x/t[i]+(double)s[i];
p[i].second = i+1;
}
for(int i=0;i<n;i++) {
if(p[i].first > p[n-1].first) {
swap(p[i], p[n-1]);
}
}
for(int i=0;i<n-1;i++) {
if(p[i].first > p[n-2].first) {
swap(p[i], p[n-2]);
}
}
if(p[n-1].first + p[n-2].first >= (double)sum) return true;
return false;
}
void solve() {
double lo = 0, hi = 500000000000000.0;
int ct = 0;
while(ct < 80) {
double mid = (lo + hi)/2;
if(decision(mid)) hi = mid;
else lo = mid;
ct ++;
}
if(p[n-1].second > p[n-2].second) {
p[n-1].second += p[n-2].second;
p[n-2].second = p[n-1].second - p[n-2].second;
p[n-1].second -= p[n-2].second;
}
printf("%d %d\n",p[n-1].second, p[n-2].second);
return;
}
int main() {
input();
solve();
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... |