이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
//days, max decrement
int n, x;
cin >> n >> x;
int days[n];
for (int i = 0; i < n; i++)
cin >> days[i];
int pref[n];
int suff[n];
int dp[n];
fill(dp, dp+n, 1000000007);
for (int i = 0; i < n; i++){
int pos = lower_bound(dp, dp+n, days[i])-dp;
dp[pos] = days[i];
pref[i] = pos+1;
}
fill(dp, dp+n, 1000000007);
for (int i = n-1; i >= 0; i--){
int pos = lower_bound(dp, dp+n, -(days[i]-x))-dp;
suff[i] = pos+1;
pos = lower_bound(dp, dp+n, -days[i])-dp;
dp[pos] = -days[i];
}
int ans = 0;
for (int i = 0; i < n; i++){
ans = max(ans, pref[i]+suff[i]-1);
}
cout<<ans<<endl;
}
| # | 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... |