답안 #483409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483409 2021-10-29T08:53:07 Z zwicky Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define nl endl
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rloop(i,a,b) for(ll i=b;i>=a;i--)
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define cm cout<<-1<<endl
#define vl vector<ll>
#define vchar vector<char>
#define vvll vector<vector<ll>>
#define vvcr vector<vchar>
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
using namespace std;

const ll MOD=1e9+7;

ll binepow(ll a,ll b,ll mod=-1){
	if(b==0){
		return 1ll;
	}
	if(mod!=-1){
		ll k=binepow(a,b/2,mod);
		if(b%2==0){
			return (k*k)%mod;
		}
		else{
			return (((k*a)%mod)*k)%mod;
		}
	}
	else{
		ll k=binepow(a,b/2,mod);
		if(b%2==0){
			return (k*k);
		}
		else{
			return k*k*a;
		}
	}
}

////////////////////////////////////////////////////////

void solve(){
	ll n,m;
	cin>>n>>m;
	vl a(n);
	loop(i,0,n){
		cin>>a[i];
	}
	vl len(n+1,-m-1);
	len[0]=0;
	// loop(i,0,n+1){
	// 	cout<<len[i]<<" ";
	// }
	ll ans=0;
	loop(i,0,n){
		ll lo=0,hi=n,k=0;
		while(lo<=hi){
			ll mid=(lo+hi)/2;
			// cout<<mid<<" ";
			if((len[mid]+m)>=a[i]){
				lo=mid+1;
				k=max(mid+1,k);
			}
			else{
				hi=mid-1;
			}
		}
		// cout<<i+1<<" "<<k<<nl;
		if(k!=0){
			// cout<<k<<" "<<a[i]<<nl;
			len[k]=max(len[k],a[i]);
			len[0]=1e10;
			ans=max(ans,k);
		}
		// cout<<nl;
	}
	cout<<(n-ans)<<nl;
	return;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -