# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
316220 | mohamedsobhi777 | 말 (IOI15_horses) | C++14 | 1600 ms | 12032 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include <bits/stdc++.h>
#pragma GCC optimize("trapv")
using namespace std;
using ll = long long;
using ld = long double;
const int _N = 5e5 + 7, mod = 1e9 + 7;
const ll inf = 2e18;
int n, m;
ll X[_N], Y[_N];
ll mul(ll x, ll y)
{
return 1ll * (x % mod) * (y % mod) % mod;
}
ll eval(int x)
{
ll ret = 1ll;
for (int i = 0; i <= x; ++i)
{
ret = mul(ret, X[i]);
}
return ret;
}
ll add(ll x, ll y)
{
return (x + y >= mod ? x + y - mod : x + y);
}
ll solve()
{
ll ret = 1ll;
ll suf = 1ll;
int i = n - 1;
int cnt = 0;
double tot = 0;
double mx = 0;
int k = 0;
int de = n - 1;
double lg = 0;
for (int j = n - 1; ~j; --j)
{
lg += log(X[j]);
de = j;
if (lg > log(1e9))
{
break;
}
}
for (int i = 0; i < de; ++i)
tot += log(X[i]);
for (int j = de; j < n; ++j)
{
tot += log(X[j]);
if (tot + log(Y[j]) > mx)
{
k = j;
mx = tot + log(Y[j]);
}
}
return mul(eval(k), Y[k]);
for (; ~i; --i)
{
suf = 1ll * suf * X[i];
//cnt += (X[i] > 1);
if (suf >= 1e9)
{
--i;
break;
}
}
ret = eval(i);
ll all = 1ll;
ll Max = 1ll;
for (++i; i < n; ++i)
{
// cout << i << " " << all << " " << Y[i] << "*\n";
all *= X[i];
Max = max(Max, 1ll * all * Y[i]);
}
//cout << "\n";
return mul(ret, Max % mod);
}
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];
}
return solve();
}
int updateX(int pos, int val)
{
X[pos] = val;
return solve();
}
int updateY(int pos, int val)
{
Y[pos] = val;
return solve();
}
컴파일 시 표준 에러 (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... |