# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132310 | ioilolcom | Horses (IOI15_horses) | C++14 | 60 ms | 8540 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>
using namespace std;
int n;
const int mod=1000000007;
const int NN=20;
const int M=1015;
int dp[NN][M];
int solve(int day,int horses, int X[], int Y[]){
if(day==n || horses==0) {
return 0;
}
if(dp[day][horses]!=-1) {
return dp[day][horses];
}
horses=horses*X[day];
int ans=0;
for(int tosell=0; tosell<=horses; tosell++) {
ans=max(ans,solve(day+1,horses-tosell,X,Y)+tosell*Y[day]);
}
ans%=mod;
return dp[day][horses]=ans;
}
int init(int N, int X[], int Y[]) {
n=N;
memset(dp,-1,sizeof dp);
int ans=solve(0,1,X,Y);
return ans;
}
int updateX(int pos, int val) {
return 0;
}
int updateY(int pos, int val) {
return 0;
}
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... |