# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
284494 | Shafin666 | Horses (IOI15_horses) | C++14 | 1587 ms | 19960 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>
#define pb push_back
#define pii pair<ll, ll>
#define nyan "(=^・ω・^=)"
#define read_input freopen("in.txt","r", stdin)
#define print_output freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;
const int maxn = 5e5+10, mod = 1e9+7;
ll x[maxn], y[maxn], n;
double lgx[maxn];
int init(int N, int X[], int Y[]) {
n = N;
for(int i = 0; i < N; i++) x[i] = X[i], y[i] = Y[i];
lgx[0] = log(x[0]);
for(int i = 1; i < N; i++) lgx[i] = lgx[i-1] + log(x[i]);
double mx = -1; int ans = 0;
for(int i = 0; i < N; i++) {
double now = lgx[i] + log(y[i]);
if(now >= mx) {
mx = now; ans = i;
}
}
ll ret = 1;
for(int i = 0; i <= ans; i++) {
ret = (ret * x[i]) % mod;
} ret = (ret * y[ans]) % mod;
return ret;
}
int updateX(int pos, int val) {
x[pos] = val;
lgx[0] = log(x[0]);
for(int i = 1; i < n; i++) lgx[i] = lgx[i-1] + log(x[i]);
double mx = -1; int ans = 0;
for(int i = 0; i < n; i++) {
double now = lgx[i] + log(y[i]);
if(now >= mx) {
mx = now; ans = i;
}
}
ll ret = 1;
for(int i = 0; i <= ans; i++) {
ret = (ret * x[i]) % mod;
} ret = (ret * y[ans]) % mod;
return ret;
}
int updateY(int pos, int val) {
y[pos] = val;
lgx[0] = log(x[0]);
for(int i = 1; i < n; i++) lgx[i] = lgx[i-1] + log(x[i]);
double mx = -1; int ans = 0;
for(int i = 0; i < n; i++) {
double now = lgx[i] + log(y[i]);
if(now >= mx) {
mx = now; ans = i;
}
}
ll ret = 1;
for(int i = 0; i <= ans; i++) {
ret = (ret * x[i]) % mod;
} ret = (ret * y[ans]) % mod;
return ret;
}
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... |