Submission #1116654

# Submission time Handle Problem Language Result Execution time Memory
1116654 2024-11-22T05:05:08 Z 12345678 Studentsko (COCI14_studentsko) C++17
100 / 100
31 ms 848 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=5e3+5;

int n, k, v[nx], t, res=INT_MAX, dp[nx];
map<int, int> mp;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>k;
    for (int i=1; i<=n; i++) cin>>v[i], mp[v[i]]=0;
    for (auto &[x, y]:mp) y=(t/k)+1, t++;
    for (int i=1; i<=n; i++) v[i]=mp[v[i]];
    for (int i=1; i<=n; i++)
    {
        dp[i]=1;
        for (int j=1; j<i; j++) if (v[j]<=v[i]) dp[i]=max(dp[i], dp[j]+1);
        res=min(res, n-dp[i]);
    }
    cout<<res;
}
# 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 24 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 592 KB Output is correct
2 Correct 21 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 768 KB Output is correct
2 Correct 26 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 848 KB Output is correct
2 Correct 12 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 592 KB Output is correct
2 Correct 24 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 768 KB Output is correct
2 Correct 26 ms 604 KB Output is correct