Submission #1025028

#TimeUsernameProblemLanguageResultExecution timeMemory
1025028I_FloPPed21Global Warming (CEOI18_glo)C++14
100 / 100
90 ms8592 KiB
#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)

glo.cpp: In function 'int main()':
glo.cpp:11:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   11 |     for ( int i = 1; i <= n ; i ++)
      |     ^~~
glo.cpp:14:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   14 |         long long maxx = 0 ;
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...