#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,x, arr[200200], p, ans, dps[200200];
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> x;
for(int i = 0; i<n; ++i) cin >> arr[i];
if(x == 0){
for(int i = 0; i<n; ++i){
int idx = lower_bound(dps, dps+p, arr[i]) - dps;
if(idx == p) ++p;
dps[idx] = arr[i];
}
cout << p;
return 0;
}
for(int d = -x; d<=x; ++d){
for(int i = 0; i<n; ++i){
for(int j = i; j<n; ++j){
p = 0;
vector<int> dp(n);
for(int k = 0; k<n; ++k){
int a = arr[k];
if(k <= j && k >= i) a+=d;
int idx = lower_bound(dp.begin(), dp.end(), a) - dp.begin();
if(idx == p) p++;
dp[idx] = a;
}
ans = max(ans, p);
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
5208 KB |
Output is correct |
2 |
Correct |
25 ms |
5208 KB |
Output is correct |
3 |
Correct |
26 ms |
5316 KB |
Output is correct |
4 |
Correct |
25 ms |
5200 KB |
Output is correct |
5 |
Correct |
15 ms |
4708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2068 ms |
3392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2045 ms |
4184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |