제출 #697139

#제출 시각아이디문제언어결과실행 시간메모리
697139kusssso학생 (COCI14_studentsko)C++17
100 / 100
37 ms716 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 5005; int n, k; int a[N]; int b[N]; int dp[N]; unordered_map<int, int> g; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i]; sort(a + 1, a + 1 + n); for (int i = 1, j = 1; i <= n; i++) { g[a[i]] = j; if (i % k == 0) j++; } int mx = 0; for (int i = 1; i <= n; i++) { b[i] = g[b[i]]; for (int j = i - 1; j >= 0; j--) { if (b[i] >= b[j]) { dp[i] = max(dp[i], dp[j] + 1); } } mx = max(mx, dp[i]); } cout << n - mx; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...