#include <bits/stdc++.h>
#define ll long long
#define vi vector
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vi vector<ll>
#define vii vector<vi>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define vc vector<char>
#define vcc vector<vc>
#define prq priority_queue
#define Dprq prq<pair<int , int> , vector<pair<int,int>> , greater<pair<int,int>>>
#define mi map<ll,ll>
#define mc map<char,int>
#define S second
#define F first
#define vp vector<pair<ll,ll>>
using namespace std;
string s , t;
int N = 1e5 + 1;
vii num(512);
set<int>st;
void dfs(int i , int n)
{
if(n >500)
return;
int x = upper_bound(all(num[n]),i) - num[n].begin();
if(x == num[n].size())
{
dfs(i , n + 1);
}
else
{
for(auto it : st)
st.insert(n ^ it);
st.insert(n);
dfs(x , n + 1);
}
}
void solve(int test)
{
ll n;
cin>>n;
ll t;
cin>>t;
vi v(n);
for (ll i = 0; i < n; i++)
{
ll x ;
cin>>x;
v[i] = t * (i + 1) - x;
}
vi dp;
for (int i = 0; i < n; i++)
{
if(v[i]<=0)
continue;
int x = upper_bound(all(dp) , v[i]) - dp.begin();
if(x == dp.size())
{
dp.push_back(v[i]);
}
else
dp[x] = v[i];
}
cout<<n - dp.size();
}
int main() {
IOS;
// freopen("cowjog.in", "r", stdin);
int t = 1;
// cin>>t;
// freopen("cowjog.out", "w", stdout);
for (int i = 1; i <=t ; ++i) {
solve(i);
cout<<"\n";
}
}
Compilation message (stderr)
triusis.cpp:8: warning: "vi" redefined
8 | #define vi vector<ll>
|
triusis.cpp:3: note: this is the location of the previous definition
3 | #define vi vector
|
# | 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... |