답안 #120561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120561 2019-06-24T23:54:47 Z sofhiasouza Mountains (IOI17_mountains) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
#include "mountains.h"
using namespace std;

const int maxn = 2010;

int dp[maxn][maxn], n, y[maxn], x[maxn];

long long int cross(int a, int b, int c)
{
	return (long long int)(x[b]-x[a])*(y[c]-y[a]) - (long long int)(y[b]-y[a])*(x[c]-x[a]);
}

int maximum_deevs(vector < int > vet)
{
	int n = vet.size();
	for(int i = 0 ; i < n ; i++)
	{
		x[i+1] = i+1;
		y[i+1] = vet[i];
	}

	for(int i = 1 ; i <= n ; i++)
	{
		dp[i][i] = dp[i-1][i] = 1;
		int ult = i-1, res = 0;

		for(int j = i-2 ; j > 0 ; j--)
		{
			if(cross(i, ult, j) >= 0)
			{
				res += dp[j+1][ult-1];
				ult = j; 
			}
			dp[j][i] = max(dp[j][i-1], 1+res+dp[j][ult-1]);
		}
	}
	return dp[1][n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -