# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832768 | 2023-08-21T14:38:20 Z | DarkMatter | Studentsko (COCI14_studentsko) | C++14 | 35 ms | 416 KB |
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int>pi; typedef pair<ll, ll>pl; typedef vector<pi>vpi; typedef vector<pl>vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef vector<string> vs; typedef vector<bool> vb; const long double PI = acos(-1); const ll oo = 1e18; const int MOD = 1e9 + 7; const int N = 2e5 + 7; #define endl '\n' #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define read(v) for (auto& it : v) scanf("%d", &it); #define readL(v) for (auto& it : v) scanf("%lld", &it); #define print(v) for (auto it : v) printf("%d ", it); puts(""); #define printL(v) for (auto it : v) printf("%lld ", it); puts(""); void solve() { int n, k; scanf("%d %d", &n, &k); vpi v(n); vi a(n), dp(n, 1); for (int i = 0; i < n; i++) { scanf("%d", &v[i].first); v[i].second = i; } sort(all(v)); int ans = 1e9; for (int i = 0; i < n; i++) a[v[i].second] = i / k; for (int i = 0; i < n; i++) { for (int j = i - 1; j >= 0; j--) if (a[j] <= a[i]) dp[i] = max(dp[i], dp[j] + 1); ans = min(ans, n - dp[i]); } printf("%d\n", ans); } int t = 1; int main() { //#ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); //#endif //scanf("%d", &t); while (t--) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 300 KB | Output is correct |
2 | Correct | 0 ms | 300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 384 KB | Output is correct |
2 | Correct | 27 ms | 316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 416 KB | Output is correct |
2 | Correct | 35 ms | 412 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 340 KB | Output is correct |
2 | Correct | 14 ms | 416 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 412 KB | Output is correct |
2 | Correct | 31 ms | 404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 340 KB | Output is correct |
2 | Correct | 33 ms | 316 KB | Output is correct |