#include <bits/stdc++.h>
#include "horses.h"
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int n;
vector<ll> X(5*maxn), Y(maxn);
vector<double> logX(5*maxn), logY(maxn);
int calc() {
ll curr = 1, id = -1, p1 = 0;
double ls = 0, double ans = 0;
for(int i=0; i<n; i++) {
curr = (curr * X[i]) % mod;
ls += logX[i];
if(ls + logY[i] > ans) {
ans = ls + logY[i];
id = i;
p1 = curr;
}
}
ll res = (p1 * Y[id]) % mod;
return (int)res;
}
int init(int N, int x[], int y[]) {
n = N;
for(int i=0; i<n; i++) {
X[i] = x[i], Y[i] = y[i];
logX[i] = log10(X[i]), logY[i] = log10(y[i]);
}
return calc();
}
int updateX(int p, int v) {
X[p] = v;
logX[p] = log10(v);
return calc();
}
int updateY(int p, int v) {
logY[p] = log10(v);
return calc();
}
Compilation message
horses.cpp: In function 'int calc()':
horses.cpp:24:20: error: expected unqualified-id before 'double'
24 | double ls = 0, double ans = 0;
| ^~~~~~
horses.cpp:29:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
29 | if(ls + logY[i] > ans) {
| ^~~
| abs