#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x,v[200005],ans,dp[200005],maxim[200005];
ll getLIS()
{
ll rez=0;
for(int i=1;i<=n;i++)
maxim[i]=-2e9;
for(int i=n;i>=1;i--)
{
int lg=0;
int st=1;
int dr=n-i;
while(st<=dr)
{
int mij=(st+dr)/2;
if(maxim[mij]>v[i])
{
lg=mij;
st=mij+1;
}
else
dr=mij-1;
}
dp[i]=lg+1;
rez=max(rez,dp[i]);
maxim[dp[i]]=max(maxim[dp[i]],v[i]);
}
return rez;
}
int main()
{
cin>>n>>x;
for(int i=1;i<=n;i++)
cin>>v[i];
ans=getLIS();
if(x==0)
{
cout<<ans;
return 0;
}
for(int i=1;i<=n;i++)
{
v[i]-=x;
ans=max(ans,getLIS());
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
25 ms |
204 KB |
Output is correct |
20 |
Correct |
22 ms |
204 KB |
Output is correct |
21 |
Correct |
22 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
11 ms |
328 KB |
Output is correct |
24 |
Correct |
14 ms |
332 KB |
Output is correct |
25 |
Correct |
10 ms |
328 KB |
Output is correct |
26 |
Correct |
10 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
4996 KB |
Output is correct |
2 |
Correct |
82 ms |
4912 KB |
Output is correct |
3 |
Correct |
81 ms |
4968 KB |
Output is correct |
4 |
Correct |
85 ms |
4924 KB |
Output is correct |
5 |
Correct |
53 ms |
4864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2089 ms |
1424 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2027 ms |
2628 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
25 ms |
204 KB |
Output is correct |
20 |
Correct |
22 ms |
204 KB |
Output is correct |
21 |
Correct |
22 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
11 ms |
328 KB |
Output is correct |
24 |
Correct |
14 ms |
332 KB |
Output is correct |
25 |
Correct |
10 ms |
328 KB |
Output is correct |
26 |
Correct |
10 ms |
332 KB |
Output is correct |
27 |
Correct |
91 ms |
4996 KB |
Output is correct |
28 |
Correct |
82 ms |
4912 KB |
Output is correct |
29 |
Correct |
81 ms |
4968 KB |
Output is correct |
30 |
Correct |
85 ms |
4924 KB |
Output is correct |
31 |
Correct |
53 ms |
4864 KB |
Output is correct |
32 |
Execution timed out |
2089 ms |
1424 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |