#include "mountains.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct pt {
ll x, y;
};
int ccw(pt a, pt b, pt c) {
ll t = (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
return t ? (t > 0 ? 1 : -1) : 0;
}
int dp[2020] = {};
int maximum_deevs(std::vector<int> y) {
int n = y.size();
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
bool flag = false;
for (int k = j + 1; k < i; k++)
if (ccw({ j,y[j] }, { i,y[i] }, { k,y[k] }) < 0) flag = true;
if (flag) dp[i] = max(dp[i], dp[j] + 1);
}
}
int ans = 0;
for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |