#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x);
#define dbgv(v);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
#ifdef ALEXPC
#define dbg(x); cout<<#x<<" = "<<x<<endl
#define dbgv(v); cout<<#v<<" = ["; trav(tv,v)cout<<"tv,";cout<<"]"<<endl
#endif
//const int N=100,M=N*N;
const ll MOD=1000*1000*1000+7;
const int N=1e6+6;
int a[N];
vector<int> lis1(N),lis2(N);
int main(){
fastio;
srng;
int n,x;
cin>>n>>x;
fill(all(lis1),INT_MAX);
fill(all(lis2),INT_MAX);
FOR(i,n){
cin>>a[i];
//cout<<a[i]<<endl;
lis2[max(lower_bound(all(lis1),a[i]+x)-lis1.begin(),lower_bound(all(lis2),a[i])-lis2.begin())]=a[i];
//cout<<i<<endl;
*lower_bound(all(lis2),a[i])=a[i];
*lower_bound(all(lis1),a[i])=a[i];
}
FOR(i,n){
if (lis2[i]==INT_MAX){
cout<<i<<endl;
return 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
8192 KB |
Output is correct |
2 |
Incorrect |
10 ms |
8192 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
8192 KB |
Output is correct |
2 |
Incorrect |
10 ms |
8192 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
8192 KB |
Output is correct |
2 |
Incorrect |
10 ms |
8192 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
11000 KB |
Output is correct |
2 |
Correct |
81 ms |
10872 KB |
Output is correct |
3 |
Correct |
80 ms |
10876 KB |
Output is correct |
4 |
Correct |
91 ms |
10944 KB |
Output is correct |
5 |
Correct |
55 ms |
10104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
8960 KB |
Output is correct |
2 |
Correct |
26 ms |
8952 KB |
Output is correct |
3 |
Correct |
25 ms |
8824 KB |
Output is correct |
4 |
Correct |
20 ms |
8704 KB |
Output is correct |
5 |
Incorrect |
9 ms |
8192 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
9592 KB |
Output is correct |
2 |
Correct |
43 ms |
9596 KB |
Output is correct |
3 |
Incorrect |
74 ms |
11036 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
8192 KB |
Output is correct |
2 |
Incorrect |
10 ms |
8192 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |