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>
#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;
vector<int> lis;
void solve(int v){
vector<int>::iterator it = lwb(all(lis), v);
if(it == lis.end()) lis.pb(v);
else *it = v;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> x;
lis.pb(0);
for(int i = 1; i <= n; ++i){
int a; cin >> a;
solve(a + x); solve(a);
}
cout << lis.size() - 1;
return 0;
}
# | 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... |