답안 #125406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125406 2019-07-05T09:00:58 Z nhho Mountains (IOI17_mountains) C++14
0 / 100
4 ms 376 KB
#include <bits/stdc++.h>
#include "mountains.h"

using namespace std;

constexpr int MAX = 2000;
int dp[MAX][MAX];

bool CanSee(int a, int b, int c, vector<int>& y) {
	return (long long)(y[c] - y[a]) * (b - a) <= (y[b] - y[a]) * (c - a);
}

int maximum_deevs(vector<int> y) {
	int n = y.size();
	for (int i = 0; i < n; i++) {
		dp[i][i] = 1;
		int la = i, add = 1;
		for (int j = i - 1; j >= 0; j--)
			if (la == i || CanSee(j, la, i, y)) {
				add += dp[j + 1][la - 1];
				la = j;
				dp[j][i] = max(dp[j][i - 1], add);
			} else
				dp[j][i] = max(dp[j][i - 1], dp[j][la - 1] + add);
	}
	return dp[0][n - 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -