Submission #363641

#TimeUsernameProblemLanguageResultExecution timeMemory
363641silverfishHoliday (IOI14_holiday)C++14
Compilation error
0 ms0 KiB
#include"holiday.h"


long long dp[3002][3002];

long long int findMaxAttraction(int n, int start, int d, int a[]) {

	//dp[i][j] : best score if i visit city i on the jth day
	dp[start][1] = a[1];
	for(int j = 2; j <= d; ++j){
		for(int i = 0; i < n; ++i){
			dp[i][j] = 0;
			for(int k = 1; k < n; ++k){
				if(j-k-1 >= 1){
					if(i-k >= 0)
						dp[i][j] = max(dp[i][j], a[i] + dp[i-k][j-k-1]);
					if(i+k < n)
						dp[i][j] = max(dp[i][j], a[i] + dp[i+k][j-k-1]);
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < n; ++i) ans = max(ans, dp[i][d]);
	return ans;
}

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:16:18: error: 'max' was not declared in this scope
   16 |       dp[i][j] = max(dp[i][j], a[i] + dp[i-k][j-k-1]);
      |                  ^~~
holiday.cpp:18:18: error: 'max' was not declared in this scope
   18 |       dp[i][j] = max(dp[i][j], a[i] + dp[i+k][j-k-1]);
      |                  ^~~
holiday.cpp:23:2: error: 'll' was not declared in this scope
   23 |  ll ans = 0;
      |  ^~
holiday.cpp:24:29: error: 'ans' was not declared in this scope
   24 |  for(int i = 0; i < n; ++i) ans = max(ans, dp[i][d]);
      |                             ^~~
holiday.cpp:24:35: error: 'max' was not declared in this scope
   24 |  for(int i = 0; i < n; ++i) ans = max(ans, dp[i][d]);
      |                                   ^~~
holiday.cpp:25:9: error: 'ans' was not declared in this scope
   25 |  return ans;
      |         ^~~