# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
492341 | 2021-12-06T19:26:48 Z | aris12345678 | Studentsko (COCI14_studentsko) | C++14 | 44 ms | 408 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; #define X first #define Y second const int mxN = 5005; pii v[mxN]; int main() { int n, k; scanf("%d %d", &n, &k); for(int i = 0; i < n; i++) { scanf("%d", &v[i].X); v[i].Y = i; } sort(v, v+n); vector<int> pos(n); for(int i = 0; i < n; i++) pos[v[i].Y] = i/k; vector<int> dp(n, 1); int ans = 1; for(int i = 0; i < n; i++) { for(int j = i-1; j >= 0; j--) { if(pos[i] >= pos[j]) dp[i] = max(dp[i], 1+dp[j]); } ans = max(ans, dp[i]); } printf("%d\n", n-ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 356 KB | Output is correct |
2 | Correct | 34 ms | 396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 344 KB | Output is correct |
2 | Correct | 44 ms | 396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 348 KB | Output is correct |
2 | Correct | 24 ms | 408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 332 KB | Output is correct |
2 | Correct | 40 ms | 396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 332 KB | Output is correct |
2 | Correct | 42 ms | 332 KB | Output is correct |