Submission #383157

#TimeUsernameProblemLanguageResultExecution timeMemory
383157vulpesStudentsko (COCI14_studentsko)C++17
100 / 100
46 ms748 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5002; int a[N], b[N], d[N]; map<int,int> m; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b + 1, b + n + 1); for (int i = 1; i <= n; i++) { m[b[i]] = (i - 1) / k; } for (int i = 1; i <= n; i++) { a[i] = m[a[i]]; } int mx = 0; for (int i = 1; i <= n; i++) { for (int j = i; j; j--) { if (a[i] >= a[j]) { d[i] = max(d[i], d[j] + 1); } } mx = max(mx, d[i]); } cout << n - mx << endl; 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...