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>
#include <ext/pb_ds/assoc_container.hpp>
#define fr first
#define se second
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = a; i > (b); --i)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define IN(i,l,r) (l<i&&i<r)
#define pb push_back
#define ones __builtin_popcountll
using namespace std;
using namespace __gnu_pbds;
template <class T>
using OSTree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef long long ll;
int n,m;
int lis(vi& a){
vi dp;
for(int v:a){
int pos = upper_bound(all(dp),v) - dp.begin();
if(pos == sz(dp)) dp.push_back(v);
else dp[pos] = v;
}
return sz(dp);
}
int main(){
cin.tie(0)->sync_with_stdio(false);
cin >> n >> m;
vi A(n+1), B;
A[0] = 0;
rep(i,1,n+1){
cin >> A[i];
}
rep(i,0,n+1){
if(i*m >= A[i]) B.pb(i*m - A[i]);
}
cout << sz(A) - lis(B) << '\n';
}
# | 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... |