This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "horses.h"
#include <vector>
#include <algorithm>
#define v vector
#define ll long long
#define MOD 1000000007
using namespace std;
v<int> xs;
v<int> ys;
int n;
// Subtask 1
// int solve() {
// int ma = 0;
// int pop = 1;
// for(int i=0; i<n; i++) {
// pop*=xs[i];
// ma = max(ma, pop*ys[i]);
// }
// return ma%MOD;
// }
// int init(int N, int X[], int Y[]) {
// n = N;
// for (int i=0; i<n; i++) {
// xs.push_back(X[i]);
// ys.push_back(Y[i]);
// }
// return solve();
// }
// int updateX(int pos, int val) {
// xs[pos] = val;
// return solve();
// }
// int updateY(int pos, int val) {
// ys[pos] = val;
// return solve();
// }
// Subtask 2
int solve() {
int max_i = n-1;
ll pop = xs[n-1];
for(int i=n-2; i>=0; i--) {
if (ys[i] > ys[max_i]*pop) {
max_i = i;
pop=1;
}
pop = min(pop*xs[i], (ll)MOD);
}
pop=1;
for(int i=0; i<=max_i; i++){
pop = (pop*xs[i])%MOD;
}
return (int) ((pop*ys[max_i])%MOD);
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i=0; i<n; i++) {
xs.push_back(X[i]);
ys.push_back(Y[i]);
}
return solve();
}
int updateX(int pos, int val) {
xs[pos] = val;
return solve();
}
int updateY(int pos, int val) {
ys[pos] = val;
return solve();
}
# | 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... |