이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define pb push_back
#define md ((b + e) >> 1)
#define lc (ind << 1)
#define rc (lc | 1)
const ll N = 5000 + 10;
const ll M = 50;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 10;
int n, X, a[N], l[N], r[N], f[N], ans;
int main() {
cin >> n >> X;
int len = 0;
for (int i = 0; i < n; i++){
cin >> a[i];
int p = lower_bound(l, l + len, a[i]) - l;
l[p] = a[i];
len = max(len, p + 1);
f[i] = p + 1;
}
ans = f[n - 1];
len = 0;
for (int i = n - 1; i >= 0; i--){
a[i] *= -1;
int p = upper_bound(r, r + len, a[i] - 1) - r;
ans = max(ans, f[i] + p);
a[i] -= X;
p = lower_bound(r, r + len, a[i]) - r;
r[p] = a[i];
len = max(len, p + 1);
}
cout << ans << '\n';
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... |