제출 #290637

#제출 시각아이디문제언어결과실행 시간메모리
290637shrek12357학생 (COCI14_studentsko)C++14
10 / 100
29 ms760 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]; 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; } dp[i] = max(dp[i], dp[j] + temp); } } cout << n-dp[n - 1] << 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...