# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652148 | pauloamed | Global Warming (CEOI18_glo) | C++14 | 2064 ms | 1500 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>
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)
# | 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... |