# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342640 | monus1042 | Horses (IOI15_horses) | C++17 | 54 ms | 20176 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;
typedef long long ll;
typedef pair<int,int> ii;
int n;
vector<int> x, y;
int dp[11][1001];
int f(int pos, int factor){
if (pos == n) return 0;
int &answer = dp[pos][factor];
if (answer > -1) return answer;
int horses = factor * x[pos];
for (int i=0; i<=horses; i++){
int delta = i * y[pos];
answer = max(answer, f(pos+1, horses - i) + delta);
}
return answer;
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i=0; i<n; i++) x.push_back(X[i]), y.push_back(Y[i]);
memset(dp, -1, sizeof dp);
return f(0, 1);
}
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... |