Submission #575168

#TimeUsernameProblemLanguageResultExecution timeMemory
575168d4xnMountains (IOI17_mountains)C++17
20 / 100
1 ms212 KiB
#include "mountains.h"
#include <bits/stdc++.h>
using namespace std;

#define ld long double
#define ll long long

const int N = 2002 + 1000;

ll n, ans;
ll dp[N];

int maximum_deevs(vector<int> y) {
	n = y.size();
	ans = 1;
	for (ll i = 0; i < n; i++) {
		dp[i] = 1;
		for (ll j = i-1; j >= 0; j--) {
			for (ll k = j+1; k < i; k++) {
				ld a = i;
				ld b = j;
				ld c = y[i];
				ld d = y[j];
				ld e = k;
				ld f = y[k];

				ld p = (c-d) / (a-b);
				ld h = d + ((e-b) * p);
				if (f > h) dp[i] = max(dp[i], dp[j]+1);
			}
		}
		ans = max(ans, dp[i]);
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...