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>
#define MIN 1
#define MAX 1000000007
#define all(a) a.begin (), a.end ()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mem(a, c) memset(a, c, sizeof(a))
using namespace std;
typedef vector <int> vi;
typedef long long int ll;
typedef pair <int, int> ii;
int n;
ll lol=MAX;
ll memo[11][1100];
vi x, y;
ll solve(ll year, ll horses ){
if(year==n-1){
ll aux=horses*x[year];
return aux*y[year];
}
if(memo[year][horses]!=-1)return memo[year][horses];
ll ans=MIN;
ll aux1=horses*x[year];
for(ll i=0;i<=horses;i++){
ans=max(ans, i*y[year]+solve(year+1, horses-i));
}return memo[year][horses]=ans;
}
int init(int N, int X[], int Y[]) {
//cout<<1<<endl;
n=N;
mem(memo, -1);
for(int i=0;i<n;i++)x.pb(X[i]);
for(int i=0;i<n;i++)y.pb(Y[i]);
cout<<solve(0, 1)<<endl;
return solve(0, 1);
}
int updateX(int pos, int val) {
return 0;
}
int updateY(int pos, int val) {
return 0;
}
/*
static char _buffer[1024];
static int _currentChar = 0;
static int _charsNumber = 0;
static FILE *_inputFile, *_outputFile;
static inline int _read() {
if (_charsNumber < 0) {
exit(1);
}
if (!_charsNumber || _currentChar == _charsNumber) {
_charsNumber = (int)fread(_buffer, sizeof(_buffer[0]), sizeof(_buffer), _inputFile);
_currentChar = 0;
}
if (_charsNumber <= 0) {
return -1;
}
return _buffer[_currentChar++];
}
static inline int _readInt() {
int c, x, s;
c = _read();
while (c <= 32) c = _read();
x = 0;
s = 1;
if (c == '-') {
s = -1;
c = _read();
}
while (c > 32) {
x *= 10;
x += c - '0';
c = _read();
}
if (s < 0) x = -x;
return x;
}
int main() {
_inputFile = fopen("horses.in", "rb");
_outputFile = fopen("horses.out", "w");
int N; N = _readInt();
int *X = (int*)malloc(sizeof(int)*(unsigned int)N);
int *Y = (int*)malloc(sizeof(int)*(unsigned int)N);
for (int i = 0; i < N; i++) {
X[i] = _readInt();
}
for (int i = 0; i < N; i++) {
Y[i] = _readInt();
}
int n;
cin>>n;
for(int i=0;i<n;i++){
int x;
cin>>x;
X[i]=x;
}
for(int i=0;i<n;i++){
int x;
cin>>x;
Y[i]=x;
}
fprintf(_outputFile,"%d\n",init(n,X,Y));
int M; M = _readInt();
for (int i = 0; i < M; i++) {
int type; type = _readInt();
int pos; pos = _readInt();
int val; val = _readInt();
if (type == 1) {
fprintf(_outputFile,"%d\n",updateX(pos,val));
} else if (type == 2) {
fprintf(_outputFile,"%d\n",updateY(pos,val));
}
}
return 0;
}
*/
Compilation message (stderr)
horses.cpp: In function 'll solve(ll, ll)':
horses.cpp:26:8: warning: unused variable 'aux1' [-Wunused-variable]
ll aux1=horses*x[year];
^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:38:17: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
return solve(0, 1);
~~~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:41:17: warning: unused parameter 'pos' [-Wunused-parameter]
int updateX(int pos, int val) {
^~~
horses.cpp:41:26: warning: unused parameter 'val' [-Wunused-parameter]
int updateX(int pos, int val) {
^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:45:17: warning: unused parameter 'pos' [-Wunused-parameter]
int updateY(int pos, int val) {
^~~
horses.cpp:45:26: warning: unused parameter 'val' [-Wunused-parameter]
int updateY(int pos, int val) {
^~~
# | 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... |