Submission #290639

#TimeUsernameProblemLanguageResultExecution timeMemory
290639shrek12357Studentsko (COCI14_studentsko)C++14
100 / 100
46 ms712 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> //#include "gondola.h" using namespace std; #define MAXN 5005 int main() { int n, k; cin >> n >> k; vector<int> order; vector<int> groups; for (int i = 0; i < n; i++) { int temp; cin >> temp; groups.push_back(temp); order.push_back(temp); } sort(groups.begin(), groups.end()); map<int, int> g; for(int i = 0; i < n; i++){ g[groups[i]] = i / k; } for (int i = 0; i < n; i++) { order[i] = g[order[i]]; } int dp[MAXN]; int ans = 0; for (int i = 0; i < n; i++) { dp[i] = 1; for (int j = 0; j < i; j++) { int temp = 0; if (order[i] >= order[j]) { temp = 1; } else { continue; } dp[i] = max(dp[i], dp[j] + temp); } ans = max(ans, dp[i]); } cout << n-ans << endl; }
#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...