#include <cstdio>
int n;
int eat[100010];
int make[100010];
int ch1, ch2;
typedef long long ll;
ll sumeat;
bool chk(double x){
int mi=-1, smi=-1;
double mv=-1e280, smv=-1e280;
for(int i=0;i<n;++i){
double cv=x*make[i]+eat[i];
if(mv < cv){
smv=mv; smi=mi;
mv=cv; mi=i;
} else if(smv<cv){
smv=cv; smi=i;
}
}
if(mv+smv >= sumeat){
ch1=mi; ch2=smi;
return true;
}
return false;
}
int main()
{
scanf("%d",&n);
int i;
for(i=0;i<n;++i) scanf("%d",eat+i), sumeat += eat[i];
for(i=0;i<n;++i) scanf("%d",make+i);
double l=0, r=1e20, mid;
for(i=0;i<100;++i){
(chk(mid=(l+r)/2)?r:l)=mid;
}
if(ch1>ch2) ch2+=ch1, ch1=ch2-ch1, ch2=ch2-ch1;
printf("%d %d\n",ch1,ch2);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
1864 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
1864 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
1864 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
1864 KB |
Output isn't correct |
2 |
Incorrect |
58 ms |
1864 KB |
Output isn't correct |
3 |
Incorrect |
51 ms |
1864 KB |
Output isn't correct |
4 |
Incorrect |
49 ms |
1864 KB |
Output isn't correct |
5 |
Incorrect |
43 ms |
1864 KB |
Output isn't correct |
6 |
Incorrect |
58 ms |
1864 KB |
Output isn't correct |
7 |
Incorrect |
42 ms |
1864 KB |
Output isn't correct |
8 |
Incorrect |
34 ms |
1864 KB |
Output isn't correct |
9 |
Incorrect |
20 ms |
1864 KB |
Output isn't correct |
10 |
Incorrect |
47 ms |
1864 KB |
Output isn't correct |
11 |
Incorrect |
59 ms |
1864 KB |
Output isn't correct |
12 |
Incorrect |
31 ms |
1864 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
1864 KB |
Output isn't correct |
2 |
Incorrect |
47 ms |
1864 KB |
Output isn't correct |
3 |
Incorrect |
47 ms |
1864 KB |
Output isn't correct |
4 |
Incorrect |
61 ms |
1864 KB |
Output isn't correct |
5 |
Incorrect |
61 ms |
1864 KB |
Output isn't correct |
6 |
Incorrect |
52 ms |
1864 KB |
Output isn't correct |
7 |
Incorrect |
63 ms |
1864 KB |
Output isn't correct |
8 |
Incorrect |
51 ms |
1864 KB |
Output isn't correct |
9 |
Incorrect |
37 ms |
1864 KB |
Output isn't correct |
10 |
Incorrect |
61 ms |
1864 KB |
Output isn't correct |
11 |
Incorrect |
51 ms |
1864 KB |
Output isn't correct |
12 |
Incorrect |
56 ms |
1864 KB |
Output isn't correct |
13 |
Incorrect |
36 ms |
1864 KB |
Output isn't correct |
14 |
Incorrect |
41 ms |
1864 KB |
Output isn't correct |
15 |
Incorrect |
62 ms |
1864 KB |
Output isn't correct |
16 |
Incorrect |
20 ms |
1864 KB |
Output isn't correct |
17 |
Incorrect |
62 ms |
1864 KB |
Output isn't correct |