# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
919125 | TIN | Studentsko (COCI14_studentsko) | C++17 | 4 ms | 828 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define FNAME "test"
const int N = 5005;
int n,k;
int v[N], x[N];
int group = 1;
map<int,int> mp;
int g[N];
int dp[N];
void Task() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cout << fixed << setprecision(9);
if (fopen(FNAME".inp","r")) {
freopen(FNAME".inp","r",stdin);
freopen(FNAME".out","w",stdout);
}
}
void Solve() {
//Your Code
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> v[i];
x[i] = v[i];
}
sort(x + 1, x + n + 1);
for (int i = 1; i <= n; i++) {
mp[x[i]] = group;
if (i % k == 0) group++;
}
for (int i = 1; i <= n; i++) g[i] = mp[v[i]];
for (int i = 0; i <= n; i++) dp[i] = -1;
dp[0] = 0;
int mx = 0;
for (int i = 1; i <= n; i++) {
if (dp[mx] <= g[i]) {
++mx;
dp[mx] = g[i];
} else {
for (int j = mx - 1; j >= 0; j--)
if (dp[j] <= g[i])
dp[j + 1] = min(dp[j + 1], g[i]);
}
}
cout << n - mx << '\n';
}
int main() {
Task();
Solve();
cerr << "\nTime run: " << 1000*clock()/CLOCKS_PER_SEC << "ms";
return 37^37;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |