#include<bits/stdc++.h>
using namespace std;
int n,x, arr[200200], p, dp[200200], ans;
int 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(dp, dp+p, arr[i]) - dp;
if(idx == p) ++p;
dp[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+1; j<n; ++j){
int a = arr[i];
int b = arr[j];
arr[i]+=d; arr[j]+=d;
memset(dp, 0, sizeof(dp)); p = 0;
for(int k = 0; k<n; ++k){
int idx = lower_bound(dp, dp+p, arr[k]) - dp;
if(idx == p) p++;
dp[idx] = arr[k];
}
ans = max(ans, p);
arr[i] = a, arr[j] = b;
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1112 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1112 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1112 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
1112 KB |
Output is correct |
2 |
Correct |
25 ms |
1112 KB |
Output is correct |
3 |
Correct |
28 ms |
1112 KB |
Output is correct |
4 |
Correct |
26 ms |
1112 KB |
Output is correct |
5 |
Correct |
15 ms |
1628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2063 ms |
1372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2031 ms |
1628 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1112 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |