제출 #955507

#제출 시각아이디문제언어결과실행 시간메모리
955507FanOfWilliamLinRabbit Carrot (LMIO19_triusis)C++17
100 / 100
22 ms4816 KiB
#include <bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//#define int long long 
#define ll long long
#define ld long double
#define ar array
#define vt vector
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define lla(v) v.rbegin(), v.rend()

//const ll MOD=1e9+7;
const ll M=(1ll<<61)-1;
const ll MOD=998244353; 

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const ll base=uniform_int_distribution<ll>(0, M-1)(rng);

ll bpow(ll a, ll b, ll DOMDOM) {
	a%=DOMDOM;
	ll res=1;
	while(b>0) {
		if(b&1)
			res=res*a%DOMDOM;
		a=a*a%DOMDOM;
		b>>=1;
	}
	return res;
}

ll floor_div(ll x, ll y) {
	assert(y!=0);
	if (y<0) {
		y=-y;
		x=-x;
	}
	if (x>=0) return x/y;
	return (x+1)/y-1;
}

ll ceil_div(ll x, ll y) {
	assert(y!=0);
	if (y<0) {
		y=-y;
		x=-x;
	}
	if (x<=0) {
		return x/y;
	}
	return (x-1)/y+1;
}

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

void tmw() {
	//solve here
	int n, m;
	cin >> n >> m;
	int a[n+1];
	for(int i=1; i<=n; ++i) {
		cin >> a[i];
	}
	vt<int> concac;
	for(int i=1; i<=n; ++i) {
		if(i*m>=a[i]) {
			concac.pb(i*m-a[i]);
		}
	}
	vt<int> dp;
	for(auto& ele: concac) {
		int pos=upper_bound(all(dp), ele)-dp.begin();
		if(pos==dp.size()) {
			dp.pb(ele);
		}
		else {
			dp[pos]=ele;
		}
	}
	cout << n-dp.size() << "\n";
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("template.inp", "r", stdin);
	//freopen("template.out", "w", stdout);	

	int TC=1;
	//cin >> TC;
	while(TC--) {
		tmw();
	}
}

컴파일 시 표준 에러 (stderr) 메시지

triusis.cpp: In function 'void tmw()':
triusis.cpp:81:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |   if(pos==dp.size()) {
      |      ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...