Submission #74424

# Submission time Handle Problem Language Result Execution time Memory
74424 2018-09-01T08:58:41 Z mjt Mountains (IOI17_mountains) C++11
Compilation error
0 ms 0 KB
#include"mountains.h"
#include<bits/stdc++.h>
using namespace std;

const int N = 2010;
int h[N];
int f[N][N];

bool pd(int a,int b,int c) {
	// ((y[a] - y[b]) / (a - b)) > ((y[a] - y[c]) / (a - c));
	return 1ll * (y[a] - y[b]) * (a - c) > 1ll * (y[a] - y[c]) * (a - b);
}
int solve(int l,int r) {
	if (f[l][r]) return f[l][r];
	if (l > r) return 0;
	if (l == r) return 1;
	int pos = -1, mx = -1;
	for (int i=l; i<=r; ++i) 
		if (h[i] > mx) pos = i, mx = h[i];
	int ans1 = solve(l, pos - 1) + solve(pos + 1, r);
	int ans2 = 0, L = pos - 1;
	for (int i=pos-2; i>=1; --i) {
		if (pd(i, L, pos)) continue;
		ans2 += solve(i + 1, L - 1);
		L = i;
	}
	return f[l][r] = max(ans1, ans2);
}

int maximum_deevs(vector<int> y) {
	n = y.size();
	for (int i=1; i<=n; ++i) h[i] = y[i - 1];
	return solve(1, n);	
}

Compilation message

mountains.cpp: In function 'bool pd(int, int, int)':
mountains.cpp:11:16: error: 'y' was not declared in this scope
  return 1ll * (y[a] - y[b]) * (a - c) > 1ll * (y[a] - y[c]) * (a - b);
                ^
mountains.cpp: In function 'int maximum_deevs(std::vector<int>)':
mountains.cpp:31:2: error: 'n' was not declared in this scope
  n = y.size();
  ^