#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9+7;
const ll INF = 1e18;
int* x;
int* y;
int n;
int init(int N, int* a, int* b) {
x = a;
y = b;
n = N;
vector<int> xx, yy;
xx.push_back(x[0]);
yy.push_back(y[0]);
for (int i=1; i<n; i++) {
if (x[i] == 1) {
yy.back() = max(yy.back(), y[i]);
}
else {
xx.push_back(x[i]);
yy.push_back(y[i]);
}
}
ll ans=0;
ll am=1;
for (int i=0; i<(int)xx.size(); i++) {
am *= xx[i];
am %= MOD;
ans = max(ans, am*yy[i]);
}
return ans;
}
int updateX(int pos, int val) {
x[pos] = val;
vector<int> xx, yy;
xx.push_back(x[0]);
yy.push_back(y[0]);
for (int i=1; i<n; i++) {
if (x[i] == 1) {
yy.back() = max(yy.back(), y[i]);
}
else {
xx.push_back(x[i]);
yy.push_back(y[i]);
}
}
ll ans=0;
ll am=1;
for (int i=0; i<(int)xx.size(); i++) {
am *= xx[i];
am %= MOD;
ans = max(ans, am*yy[i]);
}
return ans;
}
int updateY(int pos, int val) {
y[pos] = val;
vector<int> xx, yy;
xx.push_back(x[0]);
yy.push_back(y[0]);
for (int i=1; i<n; i++) {
if (x[i] == 1) {
yy.back() = max(yy.back(), y[i]);
}
else {
xx.push_back(x[i]);
yy.push_back(y[i]);
}
}
ll ans=0;
ll am=1;
for (int i=0; i<(int)xx.size(); i++) {
am *= xx[i];
am %= MOD;
ans = max(ans, am*yy[i]);
}
return ans;
}
| # | 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... |