#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
bitset<2000>ok[2000];
unordered_map<bitset<2000>, int>M;
int dp(bitset<2000> x)
{
if (x.count() == 0)
return 0;
auto it = M.find(x);
if (it != M.end())
return it->second;
int i = x._Find_first();
x[i] = false;
return M[x] = max(1 + dp(x & ok[i]), dp(x));
}
int maximum_deevs(vector<int> y)
{
M.clear();
bitset<2000>deevs;
for (ll i = 0; i < (ll)y.size(); i++)
{
ll k = i + 1;
for (ll j = i + 2; j < (ll)y.size(); j++)
{
if ((y[j] - y[i]) * (k - i) >= (y[k] - y[i]) * (j - i))
k = j;
ok[i][j] = (j != k);
}
deevs[i] = true;
}
return dp(deevs);
}/*
int main()
{
cout << maximum_deevs({ 6, 1, 5, 2, 3, 1}) << endl;//3
cout << maximum_deevs({ 0, 1, 2}) << endl;//1
}/**/
Compilation message
mountains.cpp:40:2: warning: "/*" within comment [-Wcomment]
}/**/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |