# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
802113 | jlallas384 | 말 (IOI15_horses) | C++17 | 1568 ms | 8144 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 "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
vector<int> x, y;
int n;
int solve(){
ll hv = 1;
for(int i = 0; i < n; i++){
hv = hv * x[i] % mod;
ll pre = 1;
ll bst = 0;
for(int j = i + 1; j < n; j++){
if(bst == -1) break;
pre *= x[j];
if(pre > 1e9) bst = -1;
else bst = max(bst, pre * y[j]);
}
if(bst != -1 && y[i] > bst){
return hv * y[i] % mod;
}
}
}
int init(int N, int X[], int Y[]) {
n = N;
x.resize(n), y.resize(n);
for(int i = 0; i < n; i++){
x[i] = X[i];
y[i] = Y[i];
}
return solve();
}
int updateX(int pos, int val) {
x[pos] = val;
return solve();
}
int updateY(int pos, int val) {
y[pos] = val;
return solve();
}
Compilation message (stderr)
# | 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... |