Submission #652148

#TimeUsernameProblemLanguageResultExecution timeMemory
652148pauloamedGlobal Warming (CEOI18_glo)C++14
28 / 100
2064 ms1500 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 50010; int N, X; int v[MAXN]; vector<int> lis; int ans = 0; void solve(int i){ vector<int> lis2; for(int j = i; j < N; ++j){ if(v[j] < v[i]) continue; auto it = lower_bound(lis2.begin(), lis2.end(), v[j]); if(it == lis2.end()) lis2.push_back(v[j]); else *it = v[j]; } for(int j = 0; j < lis.size(); ++j){ if(lis[j] < v[i] + X){ ans = max(ans, (j + 1) + (int) lis2.size()); } } } int main(){ cin.tie(NULL)->sync_with_stdio(false); cin >> N >> X; for(int i = 0; i < N; ++i) cin >> v[i]; for(int i = 0; i < N; ++i){ auto it = lower_bound(lis.begin(), lis.end(), v[i]); if(it == lis.end()) lis.push_back(v[i]); else *it = v[i]; if(i + 1 < N) solve(i + 1); } cout << ans << "\n"; }

Compilation message (stderr)

glo.cpp: In function 'void solve(int)':
glo.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int j = 0; j < lis.size(); ++j){
      |                  ~~^~~~~~~~~~~~
#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...