이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = (int) 2e5 + 9;
const int inf = (int) 1e9 + 9;
int n, x, a[N], lis_dp[N], brute_dp[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> x;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ans = 1;
fill(lis_dp, lis_dp + n, inf);
for (int i = 0; i < n; i++) {
int j = lower_bound(lis_dp, lis_dp + n, a[i]) - lis_dp;
lis_dp[j] = a[i];
ans = max(ans, j + 1);
}
if (x == 0) {
cout << ans << '\n';
return 0;
}
if (n * 1LL * n * 1LL * n * 2LL * x <= (int) 2e8) {
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
for (int k = -x; k <= x; k++) {
fill(brute_dp, brute_dp + n, inf);
for (int ii = 0; ii < n; ii++) {
int jj = lower_bound(brute_dp, brute_dp + n, a[ii] + (i <= ii && ii <= j) * x) - brute_dp;
brute_dp[jj] = a[ii] + (i <= ii && ii <= j) * x;
ans = max(ans, jj + 1);
}
}
}
}
cout << ans << '\n';
return 0;
}
if (n <= 1000) {
for (int i = n - 1; i >= 0; i--) {
a[i] += x;
fill(brute_dp, brute_dp + n, inf);
for (int ii = 0; ii < n; ii++) {
int jj = lower_bound(brute_dp, brute_dp + n, a[ii]) - brute_dp;
brute_dp[jj] = a[ii];
ans = max(ans, jj + 1);
}
}
cout << ans << '\n';
return 0;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |