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>
#include "horses.h"
#define ll long long int
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(i=0;i<(n);++i)
#define FORe(i,n) for(i=1;i<=(n);++i)
#define FORr(i,a,b) for(i=(a);i<(b);++i)
#define FORrev(i,n) for(i=(n);i>=0;--i)
#define F0R(i,n) for(int i=0;i<(n);++i)
#define F0Re(i,n) for(int i=1;i<=(n);++i)
#define F0Rr(i,a,b) for(ll i=(a);i<(b);++i)
#define F0Rrev(i,n) for(int i=(n);i>=0;--i)
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define ff first
#define ss second
#define cd complex<double>
#define vcd vector<cd>
#define ldd long double
#define dbgLine cout<<"Line : "<<__LINE__<<'\n'
#define all(x) (x).begin(),(x).end()
using namespace std;
/*
const short int __PRECISION = 10;
const ll MOD = 1e9+7;
const ll INF = 1e17 + 1101;
const ll LOGN = 17;
const ll MAXN = 2e5+5;
const ll ROOTN = 320;
const ldd PI = acos(-1);
const ldd EPS = 1e-7;
*/
#define MOD 1000000007
#define INF 10000000000000
int L_init(int N, int* X, int* Y)
{
ll dp[10][2000],prod = 1;
F0R(i, N) prod *= X[i];
F0R(i, prod + 1)
dp[0][i] = (i > X[0] ? -INF : (X[0] - i)*Y[0]);
F0Re(i, N-1)
F0R(j, prod + 1)
{
dp[i][j] = -INF;
F0R(k, prod + 1)
if(Y[i]*1LL*(X[i]*k - j) >= 0LL)
dp[i][j] = max(dp[i][j], dp[i-1][k] + Y[i]*1LL*(X[i]*k - j));
}
// F0R(i, N)
// F0R(j, prod)
// cout<<"dp["<<i<<"]["<<j<<"] = "<<dp[i][j]<<'\n';
return dp[N-1][0];
}
int init(int N, int* X, int* Y)
{
ll amt = 0, prod = 1;
F0R(i, N)
{
prod *= X[i];
amt = max(amt, prod*Y[i]);
}
return amt%MOD;
}
int updateX(int pos, int val){return 0;}
int updateY(int pos, int val){return 0;}
/*
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N, X[10], Y[10];
cin>>N;
F0R(i, N)
cin>>X[i];
F0R(i, N)
cin>>Y[i];
cout<<init(N, X, Y);
return 0;
}*/
Compilation message (stderr)
horses.cpp: In function 'int L_init(int, int*, int*)':
horses.cpp:60:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return dp[N-1][0];
~~~~~~~~~^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:72:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return amt%MOD;
^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:75:17: warning: unused parameter 'pos' [-Wunused-parameter]
int updateX(int pos, int val){return 0;}
^~~
horses.cpp:75:26: warning: unused parameter 'val' [-Wunused-parameter]
int updateX(int pos, int val){return 0;}
^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:76:17: warning: unused parameter 'pos' [-Wunused-parameter]
int updateY(int pos, int val){return 0;}
^~~
horses.cpp:76:26: warning: unused parameter 'val' [-Wunused-parameter]
int updateY(int pos, int val){return 0;}
^~~
# | 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... |