Submission #17499

#TimeUsernameProblemLanguageResultExecution timeMemory
17499kdh9949Studentsko (COCI14_studentsko)C++98
100 / 100
55 ms1140 KiB
#include <cstdio> #include <algorithm> using namespace std; int n, k, a[5010], b[5010], dt[5010], ans; int main(){ scanf("%d%d", &n, &k); for(int i = 0; i < n; i++){ scanf("%d", a + i); b[i] = a[i]; } sort(b, b + n); for(int i = 0; i < n; i++){ a[i] = (lower_bound(b, b + n, a[i]) - b) / k; } dt[0] = 1; for(int i = 1; i < n; i++){ dt[i] = 1; for(int j = 0; j < i; j++){ if(a[j] <= a[i]) dt[i] = max(dt[i], dt[j] + 1); } } for(int i = 1; i < n; i++) ans = max(ans, dt[i]); printf("%d", n - ans); }
#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...