| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1323291 | NgTrung2217 | Global Warming (CEOI18_glo) | C++20 | 40 ms | 2396 KiB |
#include <bits/stdc++.h>
#define task ""
#define ff first
#define ss second
using namespace std;
using ld = long double;
using ull = unsigned long long;
using ll = long long;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
const char el = '\n';
const char sp = ' ';
const ll inf = 1e18;
const int maxN = 2e5 + 5;
int n, x, a[maxN], l[maxN];
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen(task".inp", "r"))
{
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
if (!(cin >> n >> x)) return 0;
for (int i = 1; i <= n; ++i) cin >> a[i];
vector <int> v;
int ans = 0;
for (int i = 1; i <= n; ++i)
{
auto it = lower_bound(v.begin(), v.end(), a[i]);
l[i] = it - v.begin() + 1;
ans = max(ans, l[i]);
if (it != v.end()) *it = a[i];
else v.push_back(a[i]);
}
v.clear();
for (int i = n; i >= 1; --i)
{
int val = -a[i] - x;
auto it = lower_bound(v.begin(), v.end(), val);
int xd = lower_bound(v.begin(), v.end(), val + x) - v.begin();
ans = max(ans, l[i] + xd);
if (it != v.end()) *it = val;
else v.push_back(val);
}
cout << ans << el;
}
컴파일 시 표준 에러 (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... | ||||
