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>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
vector <pair <int, int> > v, sub;
cin>>n>>k;
for(int i=1; i<=n; i++){
int a;
cin>>a;
v.pb({a, i});
}
sort(v.begin(), v.end());
int y=1, i=1;
for(auto x:v){
sub.pb({x.ss, y});
if(i%k==0){
y++;
}
i++;
}
sort(sub.begin(), sub.end());
vector <int> ans;
vector <int> ::iterator itr;
for(auto x:sub){
itr=upper_bound(ans.begin(), ans.end(), x.ss);
if(itr==ans.end()){
ans.pb(x.ss);
}
}
cout<<n-ans.size();
}
# | 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... |