Submission #1101636

# Submission time Handle Problem Language Result Execution time Memory
1101636 2024-10-16T12:26:05 Z Choco Studentsko (COCI14_studentsko) C++14
100 / 100
23 ms 644 KB
#include<bits/stdc++.h>
using namespace std;
#define Study ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define ff first 
#define ss second
#define fori for(ll i=0;i<n;i++)
#define ins insert
void work(){
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll>>a(n);
    vector<ll>ca(n+1);
    vector<ll>dp(n+1,1);
    for(ll i=0;i<n;i++){
    ll num;
    cin>>num;
    a[i]={num,i};
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<n;i++){
        ll ans=i/k;
        ca[a[i].ss]=ans;
        //cout<<a[i].ff<<' '<<a[i].ss<<endl;
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<i;j++){
            if(ca[i]>=ca[j]){
                dp[i]=max(dp[i],dp[j]+1);
            }
        }
        ans=max(ans,dp[i]);
    }
    cout<<n-ans;
}
int main(){
    Study;
    ll t=1;
    //cin>>t;
    while(t--){
        work();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 592 KB Output is correct
2 Correct 18 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 592 KB Output is correct
2 Correct 23 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 592 KB Output is correct
2 Correct 13 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 592 KB Output is correct
2 Correct 22 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 592 KB Output is correct
2 Correct 23 ms 468 KB Output is correct