# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
707687 | MODDI | Horses (IOI15_horses) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
using namespace std;
const int mod = 1e9 + 7;
vi X, Y;
ll mul(ll a, ll b){
return (a * b) % mod;
}
int N;
int init(int n, int x[], int y[]){
N = n;
for(int i = 0; i < n; i++)
X.pb(x[i]);
for(int i = 0; i < n; i++)
Y.pb(y[i]);
ll ans = 0, mult = 1, pref=1, last = 0;
for(int i = 0; i < N; i++){
pref *= X[i];
mult = mul(mult, X[i]);
mult %= mod;
ll cur_sell = mul(mult, Y[i]);
cur_sell %= mod;
if(cur_sell < 0) assert(false);
if(pref * Y[i] > last){
ans = mult * Y[i] % mod;
pref = 1;
last = y[i];
}
}
if(ans <= 0) assert(false);
return ans;
}
int updateX(int pos, int val){
X[pos] = val*1ll;
ll ans = 0, mult = 1, pref=1, last = 0;
for(int i = 0; i < N; i++){
pref *= X[i];
mult = mul(mult, X[i]);
mult %= mod;
ll cur_sell = mul(mult, Y[i]);
cur_sell %= mod;
if(cur_sell < 0) assert(false);
if(pref * Y[i] > last){
ans = mult * Y[i] % mod;
pref = 1;
last = y[i];
}
}
if(ans <= 0) assert(false);
return ans;
}
int updateY(int pos, int val){
Y[pos] = val*1LL;
ll ans = 0, mult = 1, pref=1, last = 0;
for(int i = 0; i < N; i++){
pref *= X[i];
mult = mul(mult, X[i]);
mult %= mod;
ll cur_sell = mul(mult, Y[i]);
cur_sell %= mod;
if(cur_sell < 0) assert(false);
if(pref * Y[i] > last){
ans = mult * Y[i] % mod;
pref = 1;
last = y[i];
}
}
if(ans <= 0) assert(false);
return ans;
}