# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411448 | losmi247 | Horses (IOI15_horses) | C++14 | 0 ms | 0 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>
using namespace std;
typedef long long ll;
const int N = 5e2+23;
const int mod = 1000000007;
int n;
ll x[N],y[N];
ll dp[N][1005];
ll init(int n1,vector <int> x1,vector <int> y1){
n = n1;
for(int i = 1; i <= n; i++) x[i] = x1[i-1], y[i] = y1[i-1];
for(int i = 0; i <= n; i++){
for(int j = 0; j <= 1000; j++){
dp[i][j] = -1;
}
}
dp[0][1] = 0;
for(int i = 1; i <= n; i++){ /// nakon kraja i-te godine
for(ll j = 0; j <= 1000; j++){ /// imam j konja posle prodavanja
int nagore = (j+x[i]-1)/x[i];
nagore *= x[i];
for(ll pre = nagore; pre <= 1000; pre += x[i]){ /// koliko sam konja imao pre prodavanja
if(dp[i-1][pre/x[i]] != -1) dp[i][j] = max(dp[i][j],dp[i-1][pre/x[i]]+(pre-j)*y[i]);
}
}
}
return dp[n][0];
}
ll updateX(int pos,int val){
return 0;
}
ll updateY(int pos,int val){
return 0;
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int a;
cin >> a;
vector <ll> prvi,drugi;
for(int i = 1; i <= a; i++){
int x;
cin >> x;
prvi.push_back(x);
}
for(int i = 1; i <= a; i++){
int x;
cin >> x;
drugi.push_back(x);
}
cout << init(a,prvi,drugi) << endl;
}*/