#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,x;
cin >>n >> x;
vector<int>v(n);
for(int i = 0; i < n; i++){
cin >>v[i];
}
vector<int>dp(n+3,LLONG_MAX);
dp[0] = 0;
int maxi = 0;
for(int i = 0;i < n; i++){
int j = lower_bound(dp.begin(), dp.end(), v[i]+x)-dp.begin();
maxi = max(maxi, j);
dp[j] = v[i]+x;
dp[lower_bound(dp.begin(), dp.end(), v[i])- dp.begin()] = v[i];
//cout << dp;
}
cout << maxi;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
3408 KB |
Output is correct |
2 |
Correct |
30 ms |
3420 KB |
Output is correct |
3 |
Correct |
31 ms |
3408 KB |
Output is correct |
4 |
Correct |
30 ms |
3560 KB |
Output is correct |
5 |
Correct |
21 ms |
3408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1104 KB |
Output is correct |
2 |
Correct |
7 ms |
1104 KB |
Output is correct |
3 |
Correct |
8 ms |
1104 KB |
Output is correct |
4 |
Incorrect |
7 ms |
1316 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1872 KB |
Output is correct |
2 |
Correct |
16 ms |
2012 KB |
Output is correct |
3 |
Correct |
31 ms |
3408 KB |
Output is correct |
4 |
Correct |
25 ms |
3576 KB |
Output is correct |
5 |
Correct |
12 ms |
1872 KB |
Output is correct |
6 |
Correct |
23 ms |
3408 KB |
Output is correct |
7 |
Correct |
24 ms |
3408 KB |
Output is correct |
8 |
Correct |
13 ms |
1884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |