Submission #462592

# Submission time Handle Problem Language Result Execution time Memory
462592 2021-08-10T21:14:54 Z JasperL Studentsko (COCI14_studentsko) C++14
100 / 100
49 ms 484 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define maxn 5005

int n,k;
vector<pair<int,int>> v;
int a[maxn], dp[maxn];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        v.push_back({x,i});
    }
    sort(v.begin(),v.end());
    for (int i = 0; i < n; i++) {
        a[v[i].second] = i / k;
    }
    int lis = 0;
    for (int i = 0; i < n; i++) {
        dp[i] = 1;
        for (int j = 0; j < i; j++) {
            if (a[j] <= a[i]) {
                dp[i] = max(dp[i],1+dp[j]);
            }
        }
        lis = max(lis,dp[i]);
    }
    cout << n - lis << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 404 KB Output is correct
2 Correct 35 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 476 KB Output is correct
2 Correct 44 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 484 KB Output is correct
2 Correct 26 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 476 KB Output is correct
2 Correct 43 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 476 KB Output is correct
2 Correct 46 ms 476 KB Output is correct