Submission #819221

#TimeUsernameProblemLanguageResultExecution timeMemory
819221TS_2392Global Warming (CEOI18_glo)C++14
100 / 100
51 ms4232 KiB
#include <bits/stdc++.h> #define pb push_back #define lwb lower_bound #define all(x) (x).begin(), (x).end() using namespace std; const int N = 2e5 + 3; int n, x, res, dp[N], a[N]; vector<int> lis; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> x; for(int i = 1; i <= n; ++i){ cin >> a[i]; int j = lwb(all(lis), a[i]) - lis.begin(); dp[i] = j + 1; if(j == lis.size()) lis.pb(a[i]); else lis[j] = a[i]; } lis.clear(); for(int i = n; i >= 1; --i){ int j = lwb(all(lis), -a[i]) - lis.begin(); res = max(res, dp[i] + j); j = lwb(all(lis), -a[i] - x) - lis.begin(); if(j == lis.size()) lis.pb(-a[i]- x); else lis[j] = -a[i] - x; } cout << res; return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:17:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if(j == lis.size()) lis.pb(a[i]);
      |            ~~^~~~~~~~~~~~~
glo.cpp:25:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(j == lis.size()) lis.pb(-a[i]- x);
      |            ~~^~~~~~~~~~~~~
#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...