Submission #499155

# Submission time Handle Problem Language Result Execution time Memory
499155 2021-12-27T10:20:37 Z LouayFarah Studentsko (COCI14_studentsko) C++14
100 / 100
49 ms 516 KB
#include "bits/stdc++.h"

using namespace std;

#define endl "\n"
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const long long MOD = 1e9+7;
const long long INF = 1e18;

int nx[4] = {0, 0, -1, 1};
int ny[4] = {1, -1, 0, 0};


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);



    ll n, k;
    cin >> n >> k;

    vector<pair<ll, ll>> v;
    for(int i = 0; i<n; i++)
    {
        ll x;
        cin >> x;

        v.pb(mp(x, i));
    }

    sort(v.begin(), v.end());

    vector<ll> arr(n, 0);

    for(int i = 0; i<n; i++)
    {
        arr[v[i].se] = i/k;
    }

    vector<ll> dp(n, 0);
    for(int i = 0; i<n; i++)
    {
        dp[i] = 1;
        for(int j = 0; j<i; j++)
        {
            if(arr[j]<=arr[i])
                dp[i] = max(dp[i], dp[j] +1);
        }
    }

    ll maxi = 0;
    for(int i = 0; i<n; i++)
        maxi = max(maxi, dp[i]);

    cout << n - maxi << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 460 KB Output is correct
2 Correct 40 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 500 KB Output is correct
2 Correct 38 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 500 KB Output is correct
2 Correct 40 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 460 KB Output is correct
2 Correct 47 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 496 KB Output is correct
2 Correct 41 ms 500 KB Output is correct