이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3")
#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = (int)(1e9)+7;
int x[500005],y[500005],dp[15][1005],n;
ll solve(ll idx,ll nb_horses){
if(idx==n)return 0;
ll nb=(nb_horses*x[idx])%MOD;
ll ans=(nb*y[idx])%MOD;
for (ll i = nb-1LL; i >=0LL ; i--)
ans=max(ans,((solve(idx+1,nb-i)%MOD)+((i*(y[idx]%MOD))%MOD))%MOD);
return (ans%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];
memset(dp,-1,sizeof dp);
return (int)solve(0,1);
}
int updateX(int pos, int val) {
memset(dp,-1,sizeof dp);
x[pos]=val;
return (int)solve(0,1);
}
int updateY(int pos, int val) {
memset(dp,-1,sizeof dp);
y[pos]=val;
return (int)solve(0,1);
}
| # | 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... |