# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40630 | Hassoony | Studentsko (COCI14_studentsko) | C++14 | 9 ms | 1212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef unsigned long long ll;
typedef double D;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=5009;
int n,k,a[MX],dp[MX];
int bn(int l,int r,int x){
int ans=0;
while(l<=r){
int mid=(l+r)/2;
if(dp[mid]>x)r=mid-1;
else l=mid+1;
}
return l;
}
int DP(){
int ans=1;
dp[0]=a[0];
for(int i=1;i<n;i++){
if(a[i]<dp[0])dp[0]=a[i];
else if(a[i]>=dp[ans-1])dp[ans++]=a[i];
else dp[bn(0,ans,a[i])]=a[i];
}
return ans;
}
map<int,int>hashy;
int main(){
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>a[i];
hashy[a[i]]=1;
}
int tt=1,j=1;
for(auto pp:hashy){
hashy[pp.first]=tt;
if(j%k==0)++tt;
j++;
}
for(int i=0;i<n;i++)a[i]=hashy[a[i]];
cout<<n-DP()<<endl;
}
Compilation message (stderr)
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |