# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121827 | SalihSahin | Horses (IOI15_horses) | C++14 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
#define pb push_back
using namespace std;
#include "horses.h"
const long long mod = 1e9 + 7;
vector<array<long long, 2> > arr;
long long init(int N, int X[], int Y[]) {
arr.resize(N);
for(int i = 0; i < N; i++){
arr[i] = {X[i], Y[i]};
}
long long vl = 1;
int ind = 0;
for(int i = N-1; i >= 0; i--){
vl *= arr[i][0];
if(vl > mod){
ind = i;
break;
}
}
vl = 1;
long long precarp = 1;
for(int i = 0; i < ind; i++){
precarp = (precarp * arr[i][0])%mod;
}
long long ans = 0;
for(int i = ind; i < N; i++){
vl *= arr[i][0];
ans = max(ans, vl * arr[i][1]);
}
ans %= mod;
ans *= precarp;
ans %= mod;
return ans;
}
long long updateX(int pos, int val) {
int N = arr.size();
arr[pos][0] = val;
long long vl = 1;
int ind = 0;
for(int i = N-1; i >= 0; i--){
vl *= arr[i][0];
if(vl > mod){
ind = i;
break;
}
}
vl = 1;
long long precarp = 1;
for(int i = 0; i < ind; i++){
precarp = (precarp * arr[i][0])%mod;
}
long long ans = 0;
for(int i = ind; i < N; i++){
vl *= arr[i][0];
ans = max(ans, vl * arr[i][1]);
}1
ans %= mod;
ans *= precarp;
ans %= mod;
return ans;
}
long long updateY(int pos, int val){
int N = arr.size();
arr[pos][1] = val;
long long vl = 1;
int ind = 0;
for(int i = N-1; i >= 0; i--){
vl *= arr[i][0];
if(vl > mod){
ind = i;
break;
}
}
vl = 1;
long long precarp = 1;
for(int i = 0; i < ind; i++){
precarp = (precarp * arr[i][0])%mod;
}
long long ans = 0;
for(int i = ind; i < N; i++){
vl *= arr[i][0];
ans = max(ans, vl * arr[i][1]);
}
ans %= mod;
ans *= precarp;
ans %= mod;
return ans;
}