#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using ii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
using vpll = vector<pll>;
using vlld = vector<lld>;
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
#define fore(i, l, r) for (auto i = l; i < r; i++)
#define fo(i, n) fore (i, 0, n)
#define forex(i, r, l) for (auto i = r-1; i >= l; i--)
#define ffo(i, n) forex (i, n, 0)
bool cmin(ll &a, ll b) { if (b < a) { a=b; return 1; } return 0; }
bool cmax(ll &a, ll b) { if (b > a) { a=b; return 1; } return 0; }
const int N = 5e5 + 7, mod = 1e9 + 7;
int x[N], y[N], n;
int calc () {
map<int, array<int, 2>> mx;
ll suf = 1;
ffo (i, n-1) {
suf *= x[i+1];
if (suf >= 1e9) break;
mx[suf] = max(mx[suf], array<int, 2>{y[i], i});
}
ll bst = n-1;
suf = 1;
for (auto [act_suf, v]: mx) {
if (1ll*v[0] > 1ll*(act_suf/suf)*y[bst]) {
bst = v[1];
suf = act_suf;
}
}
ll ans = 1;
fo (i, bst+1) (ans *= x[i]) %= mod;
(ans *= y[bst]) %= mod;
return int(ans);
}
int init(int NN, int X[], int Y[]) {
n = NN;
fo (i, n) {
x[i] = X[i];
y[i] = Y[i];
}
return calc();
}
int updateX(int pos, int val) {
x[pos] = val;
return calc();
}
int updateY(int pos, int val) {
y[pos] = val;
return calc();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |