Submission #1115077

# Submission time Handle Problem Language Result Execution time Memory
1115077 2024-11-20T02:37:00 Z duytuandao21 Studentsko (COCI14_studentsko) C++17
100 / 100
35 ms 2640 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 2e5 + 7;
typedef pair<int, int> pii;

int n, k;
int a[N], dp[N];
pair<int, int> b[N];
map<int, int> pos;
signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> b[i].first;
        b[i].second = i;
    }
    sort (b + 1, b + 1 + n);
    int cnt = 0;
    for (int i = 1; i <= n; i += k) {
        ++cnt;
        for (int j = i; j <= i + k - 1; j++) a[b[j].second] = cnt;
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        dp[i] = 1;
        for (int j = 1; j < i; j++) 
            if (a[j] <= a[i]) dp[i] = max(dp[i], dp[j] + 1);
        res = max(res, dp[i]);
    }
    cout << n - res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2384 KB Output is correct
2 Correct 24 ms 2588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2384 KB Output is correct
2 Correct 29 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2640 KB Output is correct
2 Correct 13 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2640 KB Output is correct
2 Correct 32 ms 2528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2384 KB Output is correct
2 Correct 29 ms 2640 KB Output is correct