Submission #13952

# Submission time Handle Problem Language Result Execution time Memory
13952 2015-04-24T15:42:37 Z imsifile Be Two Bees (OJUZ10_b2b) C++
Compilation error
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
 
int n;
int h[100005], u[100005];
long long S;
 
double tmp[100005];
 
int r1, r2;
bool trial(double t){
    for (int i=0; i<n; i++) {
        tmp[i] = h[i] + t / u[i];
    }
    double ret = 0;
    auto *pt = max_element(tmp,tmp+n);
    ret += *pt;
    r1 = (int)(pt - tmp) + 1;
    *pt = -1e18;
    pt = max_element(tmp,tmp+n);
    ret += *pt;
    r2 = (int)(pt - tmp) + 1;
    return ret >= S;
}
 
int main(){
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        scanf("%d",&h[i]);
        S += h[i];
    }
    for (int i=0; i<n; i++) {
        scanf("%d",&u[i]);
    }
    double s = 0, e = 1e16;
    for (int i=0; i<100; i++) {
        double m = (s+e)/2;
        if(trial(m)) e = m;
        else s = m;
    }
    printf("%d %d",min(r1,r2),max(r1,r2));
}

Compilation message

b2b.cpp: In function ‘bool trial(double)’:
b2b.cpp:18:5: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
     auto *pt = max_element(tmp,tmp+n);
     ^
b2b.cpp:18:11: error: ISO C++ forbids declaration of ‘pt’ with no type [-fpermissive]
     auto *pt = max_element(tmp,tmp+n);
           ^
b2b.cpp:18:37: error: cannot convert ‘double*’ to ‘int*’ in initialization
     auto *pt = max_element(tmp,tmp+n);
                                     ^
b2b.cpp:20:21: error: invalid operands of types ‘int*’ and ‘double [100005]’ to binary ‘operator-’
     r1 = (int)(pt - tmp) + 1;
                     ^
b2b.cpp:21:9: warning: overflow in implicit constant conversion [-Woverflow]
     *pt = -1e18;
         ^
b2b.cpp:22:8: error: cannot convert ‘double*’ to ‘int*’ in assignment
     pt = max_element(tmp,tmp+n);
        ^
b2b.cpp:24:21: error: invalid operands of types ‘int*’ and ‘double [100005]’ to binary ‘operator-’
     r2 = (int)(pt - tmp) + 1;
                     ^
b2b.cpp: In function ‘int main()’:
b2b.cpp:29:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
b2b.cpp:31:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&h[i]);
                          ^
b2b.cpp:35:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&u[i]);
                          ^