Submission #383157

# Submission time Handle Problem Language Result Execution time Memory
383157 2021-03-28T23:07:35 Z vulpes Studentsko (COCI14_studentsko) C++17
100 / 100
46 ms 748 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5002;
int a[N], b[N], d[N];
map<int,int> m;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i]; b[i] = a[i];
    }
    sort(b + 1, b + n + 1);
    for (int i = 1; i <= n; i++) {
        m[b[i]] = (i - 1) / k;
    }
    for (int i = 1; i <= n; i++) {
        a[i] = m[a[i]];
    }
    int mx = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j; j--) {
            if (a[i] >= a[j]) {
                d[i] = max(d[i], d[j] + 1);
            }
        }
        mx = max(mx, d[i]);
    }
    cout << n - mx << endl;
    return 0;
}
# 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 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 620 KB Output is correct
2 Correct 37 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 748 KB Output is correct
2 Correct 42 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 744 KB Output is correct
2 Correct 27 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 620 KB Output is correct
2 Correct 41 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 620 KB Output is correct
2 Correct 42 ms 620 KB Output is correct