Submission #14341

# Submission time Handle Problem Language Result Execution time Memory
14341 2015-05-12T10:06:30 Z comet Be Two Bees (OJUZ10_b2b) C++
0 / 100
1000 ms 4324 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
double sum,H[111111],T[111111],a[111111];
bool check(double k){
    for(int i=0;i<n;i++)a[i]=H[i]+k*T[i];
    sort(a,a+n);
    double ret=0;
    for(int i=0;i<n-2;i++)ret+=a[i];
    //printf("%f : %f\n",ret,k*sum);
    return ret<=k*sum;
}
void output(double k){
    double Max=0;
    int v,v2;
    for(int i=0;i<n;i++)a[i]=H[i]+k*T[i];
    for(int i=0;i<n;i++){
        if(Max<a[i]){
            Max=a[i];
            v=i;
        }
    }
    Max=0;
    for(int i=0;i<n;i++){
        if(Max<a[i]&&i!=v){
            Max=a[i];
            v2=i;
        }
    }
    printf("%d %d\n",v+1,v2+1);
}
int main(){
    scanf("%d",&n);
    int x,y,z;
    for(int i=0;i<n;i++)scanf("%lf",&H[i]);
    for(int i=0;i<n;i++){
        scanf("%lf",&T[i]);
		T[i]=1/T[i];
        sum+=T[i];
    }
    double lo=0,hi=1e9,mid;
    for(int i=0;i<100;i++){
        mid=(lo+hi)/2;
        if(check(mid)){
            hi=mid;
        }
        else{
            lo=mid;
        }
       // printf("%f %f\n",lo,hi);
    }
    output(hi);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 4324 KB Output isn't correct
2 Incorrect 0 ms 4324 KB Output isn't correct
3 Incorrect 0 ms 4324 KB Output isn't correct
4 Correct 0 ms 4324 KB Output is correct
5 Incorrect 0 ms 4324 KB Output isn't correct
6 Incorrect 0 ms 4324 KB Output isn't correct
7 Incorrect 0 ms 4324 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4324 KB Output is correct
2 Incorrect 0 ms 4324 KB Output isn't correct
3 Incorrect 4 ms 4324 KB Output isn't correct
4 Incorrect 0 ms 4324 KB Output isn't correct
5 Incorrect 0 ms 4324 KB Output isn't correct
6 Incorrect 4 ms 4324 KB Output isn't correct
7 Correct 4 ms 4324 KB Output is correct
8 Incorrect 5 ms 4324 KB Output isn't correct
9 Incorrect 0 ms 4324 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 275 ms 4324 KB Output is correct
2 Incorrect 686 ms 4324 KB Output isn't correct
3 Correct 932 ms 4324 KB Output is correct
4 Execution timed out 1000 ms 4324 KB Program timed out
5 Correct 449 ms 4324 KB Output is correct
6 Incorrect 555 ms 4324 KB Output isn't correct
7 Correct 982 ms 4324 KB Output is correct
8 Execution timed out 1000 ms 4324 KB Program timed out
9 Correct 982 ms 4324 KB Output is correct
10 Correct 759 ms 4324 KB Output is correct
11 Incorrect 311 ms 4324 KB Output isn't correct
12 Correct 267 ms 4324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 4324 KB Program timed out
2 Execution timed out 1000 ms 4324 KB Program timed out
3 Correct 678 ms 4324 KB Output is correct
4 Correct 682 ms 4324 KB Output is correct
5 Execution timed out 1000 ms 4324 KB Program timed out
6 Correct 662 ms 4324 KB Output is correct
7 Execution timed out 1000 ms 4324 KB Program timed out
8 Execution timed out 1000 ms 4324 KB Program timed out
9 Execution timed out 1000 ms 4324 KB Program timed out
10 Incorrect 995 ms 4324 KB Output isn't correct
11 Execution timed out 1000 ms 4324 KB Program timed out
12 Correct 641 ms 4324 KB Output is correct
13 Incorrect 153 ms 4324 KB Output isn't correct
14 Incorrect 563 ms 4324 KB Output isn't correct
15 Execution timed out 1000 ms 4324 KB Program timed out
16 Correct 999 ms 4324 KB Output is correct
17 Correct 991 ms 4324 KB Output is correct