# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500999 | AmirElarbi | Horses (IOI15_horses) | C++14 | 13 ms | 10536 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 <bits/stdc++.h>
#include "horses.h"
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 1e9
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
ll x[1005],y[1005];
ll dp[1005];
int n;
ll srch(int i, ll nb){
if(i == n) return 0;
if(dp[i]!=-1)return dp[i];
return dp[i] = max(srch(i+1,(nb%MOD*x[i]%MOD)%MOD)%MOD, ((nb%MOD*x[i]%MOD)%MOD*y[i])%MOD);
}
int init(int N, int X[], int Y[]) {
n = N;
memset(dp,-1,sizeof dp);
for (int i = 0; i < n; ++i)
{
x[i] = X[i];
y[i] = Y[i];
}
return srch(0,1)%MOD;
}
int updateX(int pos, int val) {
x[pos] = val;
memset(dp,-1,sizeof dp);
return srch(0,1)%MOD;
}
int updateY(int pos, int val) {
y[pos] = val;
memset(dp,-1,sizeof dp);
return srch(0,1)%MOD;
}
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... |