Submission #650850

# Submission time Handle Problem Language Result Execution time Memory
650850 2022-10-15T18:21:20 Z edogawa_something Studentsko (COCI14_studentsko) C++14
100 / 100
44 ms 852 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef string st;
typedef bool bl;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
#define pu push
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);cin.tie();
#define test ll qqqqq;cin>>qqqqq;while(qqqqq--)
#define F first
#define S second
#define forn(i,n) for(ll i=0;i<n;i++)
#define forx(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define pob pop_back
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define ub upper_bound
#define pof pop_front
const ll dx[]{1,0,-1,0};
const ll dy[]{0,1,0,-1};
const ll inf=2e18;
const ll mod=1e9+7;
const ll M=1e6+1;
const ll MM=10002;
const ll MMM=101;
const ld pi=acos(-1);
const ll mod1=1000000321;
ll n,k,a[MM],b[MM],dp[MM];
map<ll,ll>mp;
ll LIS(){
    ll ret=0;
    dp[0]=1;
    forx(i,1,n){
        forn(j,i){
            if(a[j]<=a[i])
            dp[i]=max(dp[i],dp[j]);
        }
        dp[i]++;
        ret=max(ret,dp[i]);
    }
    return ret;
}
int main(){
    fast
    memset(dp,0,sizeof dp);
    cin>>n>>k;
    forn(i,n)
    cin>>a[i],b[i]=a[i];
    sort(b,b+n);
    forn(i,n/k){
        forn(j,k)
        mp[b[i*k+j]]=i;
    }
    forn(i,n)
    a[i]=mp[a[i]];
    cout<<n-LIS();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 724 KB Output is correct
2 Correct 31 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 724 KB Output is correct
2 Correct 42 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 784 KB Output is correct
2 Correct 27 ms 788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 724 KB Output is correct
2 Correct 38 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 724 KB Output is correct
2 Correct 40 ms 828 KB Output is correct