#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define h first
#define t second
const ll INF = 1LL<<60;
int n;
pll arr[100100];
double x;
ll S;
bool cmp(pll a, pll b) {
return x/a.t+a.h<x/b.t+b.h;
}
pll m1, m2;
int t1, t2;
bool ok() {
m1=pll(-1000000,1000000), m2 = pll(-1000000,1000000);
int i;
for (i=0;i<n;i++) {
if (cmp(m1,arr[i])) m2=m1,m1=arr[i],t2=t1,t1=i;
else if (cmp(m2,arr[i])) m2=arr[i],t2=i;
}
return (double)(S-m1.h-m2.h)/(1.0/m1.t+1.0/m2.t)<=x;
}
void process() {
int i;
double s = 0, e = INF;
for (i=0;i<300;i++) {
x = (s+e)/2;
if (ok()) e=x;
else s=x;
}
printf("%d %d\n",min(t1,t2)+1,max(t1,t2)+1);
}
void input() {
int i;
scanf("%d",&n);
for (i=0;i<n;i++) scanf("%lld",&arr[i].h), S += arr[i].h;
for (i=0;i<n;i++) scanf("%lld",&arr[i].t);
}
int main() {
input();
process();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
0 ms |
2648 KB |
Output is correct |
4 |
Correct |
0 ms |
2648 KB |
Output is correct |
5 |
Correct |
0 ms |
2648 KB |
Output is correct |
6 |
Correct |
0 ms |
2648 KB |
Output is correct |
7 |
Correct |
0 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2648 KB |
Output is correct |
2 |
Correct |
7 ms |
2648 KB |
Output is correct |
3 |
Correct |
8 ms |
2648 KB |
Output is correct |
4 |
Correct |
6 ms |
2648 KB |
Output is correct |
5 |
Correct |
10 ms |
2648 KB |
Output is correct |
6 |
Correct |
10 ms |
2648 KB |
Output is correct |
7 |
Correct |
4 ms |
2648 KB |
Output is correct |
8 |
Correct |
10 ms |
2648 KB |
Output is correct |
9 |
Correct |
0 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
938 ms |
2648 KB |
Output is correct |
2 |
Correct |
457 ms |
2648 KB |
Output is correct |
3 |
Correct |
311 ms |
2648 KB |
Output is correct |
4 |
Correct |
924 ms |
2648 KB |
Output is correct |
5 |
Correct |
603 ms |
2648 KB |
Output is correct |
6 |
Correct |
606 ms |
2648 KB |
Output is correct |
7 |
Correct |
419 ms |
2648 KB |
Output is correct |
8 |
Correct |
605 ms |
2648 KB |
Output is correct |
9 |
Correct |
612 ms |
2648 KB |
Output is correct |
10 |
Correct |
439 ms |
2648 KB |
Output is correct |
11 |
Correct |
937 ms |
2648 KB |
Output is correct |
12 |
Correct |
356 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
945 ms |
2648 KB |
Output is correct |
2 |
Correct |
943 ms |
2648 KB |
Output is correct |
3 |
Correct |
439 ms |
2648 KB |
Output is correct |
4 |
Correct |
669 ms |
2648 KB |
Output is correct |
5 |
Correct |
712 ms |
2648 KB |
Output is correct |
6 |
Correct |
938 ms |
2648 KB |
Output is correct |
7 |
Correct |
313 ms |
2648 KB |
Output is correct |
8 |
Correct |
621 ms |
2648 KB |
Output is correct |
9 |
Correct |
692 ms |
2648 KB |
Output is correct |
10 |
Correct |
945 ms |
2648 KB |
Output is correct |
11 |
Correct |
443 ms |
2648 KB |
Output is correct |
12 |
Correct |
751 ms |
2648 KB |
Output is correct |
13 |
Correct |
622 ms |
2648 KB |
Output is correct |
14 |
Correct |
895 ms |
2648 KB |
Output is correct |
15 |
Correct |
940 ms |
2648 KB |
Output is correct |
16 |
Correct |
654 ms |
2648 KB |
Output is correct |
17 |
Correct |
932 ms |
2648 KB |
Output is correct |