| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 910583 | pan | Global Warming (CEOI18_glo) | C++17 | 89 ms | 6604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#include "bits_stdc++.h"
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
int main()
{
ll n,x;
cin >> n >> x;
ll arr[n], right[n];
vector<ll> lis;
for (ll i=0; i<n; ++i) cin >> arr[i];
for (ll i=n-1; i>=0; --i)
{
ll ind = lb(lis.begin(), lis.end(), -arr[i])-lis.begin();
if (ind>=lis.size())
{
lis.pb(-arr[i]);
}
else
{
lis[ind] = -arr[i];
}
right[i] = ind;
}
ll ans = 0;
lis.resize(0);
for (ll i=0; i<n; ++i)
{
ll left = lb(lis.begin(), lis.end(), arr[i]+x) -lis.begin();
ans = max(ans, left + right[i] + 1);
ll ind = lb(lis.begin(), lis.end(), arr[i]) -lis.begin();
if (ind>=lis.size()) lis.pb(arr[i]);
else lis[ind] = arr[i];
}
cout << ans << endl;
return 0;
}
Compilation message (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... | ||||
