// 0 indexed btw
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define arr array
const int N = 5e5 + 5;
const lint MD = 1e9 + 7;
int n;
arr<lint, N> grw, prc;
lint md(lint x) { return (x + MD) % MD; }
lint slv() {
int bst = 0;
lint grw_prd = 1;
for (int i = 1; i <= n; i++) {
grw_prd *= grw[i];
if (grw_prd > prc[bst] || grw_prd * prc[i] > prc[bst]) {
bst = i;
grw_prd = 1;
}
}
lint ans = prc[bst];
for (int i = 1; i <= bst; i++) ans = md(ans * grw[i]);
return ans;
}
int init(int _n, int _grw[], int _prc[]) {
n = _n;
for (int i = 1; i <= n; i++) grw[i] = _grw[i - 1], prc[i] = _prc[i - 1];
return slv();
}
int updateX(int id, int vl) {
id++, grw[id] = vl;
return slv();
}
int updateY(int id, int vl) {
id++, prc[id] = vl;
return slv();
}
# | 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... |