# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148092 | WhipppedCream | Global Warming (CEOI18_glo) | C++17 | 102 ms | 4988 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;
int n, x;
const int maxn = 2e5+5;
int arr[maxn];
int L[maxn];
int lis[maxn];
int lds[maxn];
int main()
{
scanf("%d %d", &n, &x);
for(int i = 1; i<= n; i++) scanf("%d", arr+i);
int cur = 0;
for(int i = n; i>= 1; i--)
{
int tmp = lower_bound(L, L+cur, -arr[i])-L;
L[tmp] = -arr[i];
cur = max(cur, tmp+1);
lds[i] = tmp+1;
}
cur = 0;
int best = 0;
for(int i = 1; i<= n; i++)
{
best = max(best, lds[i]+(int) (lower_bound(L, L+cur, arr[i]+x)-L));
int tmp = lower_bound(L, L+cur, arr[i])-L;
L[tmp] = arr[i];
cur = max(cur, tmp+1);
lis[i] = cur;
//printf("%d: %d\n", i, best);
}
best = max(best, lis[n]);
printf("%d\n", best);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |