#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 100003, mod = 1e9 + 7, inf = 1e9 + 7;
ll lis(vector<ll>& a){
vector<ll> dp;
for(auto i : a){
auto j = upper_bound(dp.begin(), dp.end(), i) - dp.begin();
if(j == dp.size()){
dp.push_back(i);
}
else{
dp[j] = i;
}
}
return dp.size();
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("cowjog.in", "r", stdin);
// freopen("cowjog.out", "w", stdout);
ll n, m;
cin >> n >> m;
vector<ll> v(n + 1), g;
v[0] = 0;
for(ll i = 1; i <= n; ++i){
cin >> v[i];
v[i] -= m * i;
}
int i = 1;
while(v[i - 1] >= v[i]){
i++;
}
for(int j = i; j <= n; ++j){
g.push_back(v[j]);
}
cout << lis(g);
}
Compilation message
triusis.cpp: In function 'll lis(std::vector<long long int>&)':
triusis.cpp:13:14: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | if(j == dp.size()){
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |