제출 #1157167

#제출 시각아이디문제언어결과실행 시간메모리
1157167tegsheeRabbit Carrot (LMIO19_triusis)C++20
100 / 100
20 ms3400 KiB
#include<bits/stdc++.h>
#define int long long
#define ss second
#define ff first
#define pb push_back
using namespace std;
const int mxn=2e5+4;
const int inf=1e12;
int n,m;
int a[mxn],dp[mxn];
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=0; i<n; i++) {
    	cin>>a[i];
    	a[i]=(i+1)*m-a[i];
    }
    dp[0]=-inf;
    for(int i=1; i<=n; i++) {
    	dp[i]=inf;
	}
    for(int i=0; i<n; i++){
    	if(a[i]<0) continue;
    	int j=upper_bound(dp,dp+n+1,a[i])-dp;
		  if(dp[j-1]<=a[i]) dp[j]=min(dp[j],a[i]);
    }
   	int k=0;
   	for(int i=1; i<=n; i++) {
   		if(dp[i]<inf) k=i;
	   }
  	cout<<n-k;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...