# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234247 | jhtan | Horses (IOI15_horses) | C++14 | 1592 ms | 20088 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 <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll V[500000];
ll XX[500000];
ll YY[500000];
ll MX[500000];
ll MY[500000];
int n;
int init(int N, int X[], int Y[]) {
// For 17 points
/*
int V[N];
V[0] = X[0];
for(int i=1; i<N; i++) V[i] = V[i-1] * X[i];
int mx = 0;
for(int i=0; i<N; i++) mx = max(mx, V[i] * Y[i]);
*/
n = N;
for(int i=0; i<N; i++) {
YY[i] = Y[i];
XX[i] = X[i];
}
MX[0] = X[0] / MOD;
V[0] = X[0] % MOD;
for(int i=1; i<N; i++) {
ll m = V[i-1] * X[i];
MX[i] = (m / MOD) + (MX[i-1] * X[i]);
V[i] = m % MOD;
}
ll mm = 0, mx = 0;
for(int i=0; i<N; i++) {
ll m1 = MX[i] * Y[i] + ((V[i] * Y[i]) / MOD);
ll m2 = (V[i] * Y[i]) % MOD;
if(m1 > mm) {
mm = m1;
mx = m2;
} else if (m1 == mm && m2 > mx) {
mx = m2;
}
}
return mx;
}
int updateX(int pos, int val) {
XX[pos] = val;
for(int i=pos; i<n; i++) {
ll m = V[i-1] * XX[i];
MX[i] = (m / MOD) + (MX[i-1] * XX[i]);
V[i] = m % MOD;
}
ll mm = 0, mx = 0;
for(int i=0; i<n; i++) {
ll m1 = MX[i] * YY[i] + ((V[i] * YY[i]) / MOD);
ll m2 = (V[i] * YY[i]) % MOD;
if(m1 > mm) {
mm = m1;
mx = m2;
} else if (m1 == mm && m2 > mx) {
mx = m2;
}
}
return mx;
}
int updateY(int pos, int val) {
YY[pos] = val;
ll mm = 0, mx = 0;
for(int i=0; i<n; i++) {
ll m1 = MX[i] * YY[i] + ((V[i] * YY[i]) / MOD);
ll m2 = (V[i] * YY[i]) % MOD;
if(m1 > mm) {
mm = m1;
mx = m2;
} else if (m1 == mm && m2 > mx) {
mx = m2;
}
}
return mx;
}
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... |