Submission #211609

#TimeUsernameProblemLanguageResultExecution timeMemory
211609DavidDamianHorses (IOI15_horses)C++11
17 / 100
26 ms12284 KiB
#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)

horses.cpp: In function 'int updateX(int, int)':
horses.cpp:37:17: warning: unused parameter 'pos' [-Wunused-parameter]
 int updateX(int pos, int val) {
                 ^~~
horses.cpp:37:26: warning: unused parameter 'val' [-Wunused-parameter]
 int updateX(int pos, int val) {
                          ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:41:17: warning: unused parameter 'pos' [-Wunused-parameter]
 int updateY(int pos, int val) {
                 ^~~
horses.cpp:41:26: warning: unused parameter 'val' [-Wunused-parameter]
 int updateY(int pos, int val) {
                          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...