# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211609 | DavidDamian | Horses (IOI15_horses) | C++11 | 26 ms | 12284 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 memo[11][1005];
int n;
int x[100005];
int y[100005];
int maxProfit(int i,int h)
{
if(i==n-1) return h*y[i];
if(h==0) return 0;
if(memo[i][h]==-1){
int maximum=0;
for(int j=0;j<=h;j++){
maximum=max(maximum,
maxProfit(i+1,(h-j)*x[i+1])+j*y[i]);
}
memo[i][h]=maximum;
}
return memo[i][h];
}
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];
}
for(int i=0;i<N;i++){
for(int j=0;j<1005;j++){
memo[i][j]=-1;
}
}
int maximum=maxProfit(0,x[0]);
return maximum;
}
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... |