// game.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
// ttetris.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int xh;
cin >> xh;
vector<int>v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i];
}
if (xh == 0)
{
vector <int>p1(1, -100000000);
for (int i = 0; i < n; i++)
{
int a;
a = v[i];
int x = lower_bound(p1.begin(), p1.end(), a) - p1.begin();
if (x == p1.size())p1.push_back(a);
else p1[x] = a;
}
cout << p1.size()-1 << endl;
}
else
{
int maxs = 0;
for (int i = 0; i < n; i++)
{
for (int j = i; j < n; j++)
{
for (int d = -1 * xh; d <= xh; d++)
{
///
vector<int>vn = v;
for (int k = i; k <= j; k++)
{
vn[k] += d;
}
///najdlhsia stupajuca postupnost
vector <int>p(1, -100000000);
for (int k = 0; k < n; k++)
{
int a = vn[k];
int x = lower_bound(p.begin(), p.end(), a) - p.begin();
if (x == p.size())p.push_back(a);
else p[x] = a;
}
int velkost = p.size();
if (velkost-1 > maxs)
{
maxs = velkost - 1;
/*cout << i << ' ';
cout << j << endl;
cout << d << endl;
cout << velkost - 1 << endl;
for (int k = 0; k < p.size(); k++)
{
cout << p[k];
if (k == p.size() - 1)
{
cout << endl;
}
else
{
cout << ' ';
}
}*/
}
}
}
}
cout << maxs << endl;
}
return 0;
//std::cout << "Hello World!\n";
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Compilation message
glo.cpp: In function 'int main()':
glo.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if (x == p1.size())p1.push_back(a);
| ~~^~~~~~~~~~~~
glo.cpp:56:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | if (x == p.size())p.push_back(a);
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
288 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
288 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
26 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
288 KB |
Output is correct |
14 |
Correct |
89 ms |
272 KB |
Output is correct |
15 |
Correct |
53 ms |
204 KB |
Output is correct |
16 |
Correct |
49 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
288 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
26 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
288 KB |
Output is correct |
14 |
Correct |
89 ms |
272 KB |
Output is correct |
15 |
Correct |
53 ms |
204 KB |
Output is correct |
16 |
Correct |
49 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Execution timed out |
2067 ms |
256 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
2992 KB |
Output is correct |
2 |
Correct |
103 ms |
2984 KB |
Output is correct |
3 |
Correct |
106 ms |
2988 KB |
Output is correct |
4 |
Correct |
98 ms |
2888 KB |
Output is correct |
5 |
Correct |
69 ms |
2840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2077 ms |
1180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2078 ms |
1988 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
288 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
26 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
288 KB |
Output is correct |
14 |
Correct |
89 ms |
272 KB |
Output is correct |
15 |
Correct |
53 ms |
204 KB |
Output is correct |
16 |
Correct |
49 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Execution timed out |
2067 ms |
256 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |