# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1025028 | I_FloPPed21 | Global Warming (CEOI18_glo) | C++14 | 90 ms | 8592 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 <iostream>
#include <vector>
using namespace std;
long long n , x,v[200005],pref[200005];
int main()
{
cin >> n >> x;
vector<long long> dp (n+1,1e9);
for ( int i = 1; i <= n ; i ++)
cin >> v[i];
long long maxx = 0 ;
for ( int i = 1; i <= n ; i ++ )
{
long long poz = lower_bound(dp.begin(),dp.end(),v[i]) - dp.begin();
maxx = max ( maxx , poz );
dp[poz]= v[i];
pref[i] = poz + 1;
}
dp = vector<long long> (n+1,1e9);
for ( int i = n ; i >= 1; i -- )
{
long long poz = lower_bound(dp.begin(),dp.end(),-v[i]) - dp.begin();
long long cox = lower_bound(dp.begin(),dp.end(),-v[i]+x) - dp.begin();
maxx = max ( maxx, pref[i] + cox);
dp[poz] = -v[i];
}
cout << maxx << '\n';
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... |