# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
609808 | jairRS | Horses (IOI15_horses) | C++17 | 15 ms | 8276 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 MAXN = 1000;
const ll MOD = 1e9 + 7;
int gN, gX[MAXN], gY[MAXN];
struct bignum{
ll val = 0;
bool overMOD = false;
bignum(ll _val){
overMOD = val/(MOD + 1);
val = _val % MOD;
}
void scale(ll x){
bignum newBignum = bignum(val * x);
overMOD |= newBignum.overMOD;
val = newBignum.val;
}
};
int getAns(){
bignum curAns(gY[gN - 1] * gX[gN - 1]);
for (int i = gN - 2; i >= 0; i--)
{
if(!curAns.overMOD && gY[i] > curAns.val)
curAns = bignum(gY[i] * gX[i]);
else{
curAns.scale(gX[i]);
}
}
return curAns.val;
}
int init(int N, int X[], int Y[]) {
gN = N;
for (int i = 0; i < N; i++)
{
gX[i] = X[i];
gY[i] = Y[i];
}
return getAns();
}
int updateX(int pos, int val) {
gX[pos] = val;
return getAns();
}
int updateY(int pos, int val) {
gY[pos] = val;
return getAns();
}
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... |