Submission #320280

# Submission time Handle Problem Language Result Execution time Memory
320280 2020-11-08T08:07:50 Z kaplanbar Studentsko (COCI14_studentsko) C++14
100 / 100
43 ms 748 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 5005;
int n, k, a[N], dp[N];
map<int,int> mp;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mp[x] = i;
    }
    int c = 0;
    for(auto x : mp) {
        a[x.second] = c / k;
        c++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        dp[i] = 1;
        for(int j = i - 1; j >= 0; j--) {
            if(a[j] <= a[i]) dp[i] = max(dp[i], dp[j] + 1);
        }
        ans = max(ans, dp[i]);
    }
    cout << n - ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 620 KB Output is correct
2 Correct 40 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 620 KB Output is correct
2 Correct 41 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 624 KB Output is correct
2 Correct 26 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 620 KB Output is correct
2 Correct 42 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 620 KB Output is correct
2 Correct 42 ms 704 KB Output is correct