이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define popb pop_back
#define all(A) A.begin(),A.end()
#define rall(A) A.rbegin(),A.rend()
#define dic unordered_map
#define bpc __builtin_popcountll//numero de bits para long long
#define bclz __builtin_clzll//leading zeros para ll
#define max_bit(A) 31-__builtin_clz(A)
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(12) << fixed;
int n,m;
cin>>n>>m;
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i],a[i]=(i+1)*m-a[i];
//for(int i=0;i<n;i++) cout<<a[i]<<" ";
//cout<<"\n";
vector<int> lis;
for(int i=0;i<n;i++){
if(a[i]>=0){
if(lis.size()==0 || lis.back()<=a[i]) lis.pb(a[i]);
else{
int pos=upper_bound(all(lis),a[i])-lis.begin();
lis[pos]=a[i];
}
}
}
cout<<n-lis.size()<<"\n";
return 0;
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* bitwise and boolean operations
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/
# | 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... |