Submission #462592

#TimeUsernameProblemLanguageResultExecution timeMemory
462592JasperLStudentsko (COCI14_studentsko)C++14
100 / 100
49 ms484 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define maxn 5005 int n,k; vector<pair<int,int>> v; int a[maxn], dp[maxn]; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back({x,i}); } sort(v.begin(),v.end()); for (int i = 0; i < n; i++) { a[v[i].second] = i / k; } int lis = 0; for (int i = 0; i < n; i++) { dp[i] = 1; for (int j = 0; j < i; j++) { if (a[j] <= a[i]) { dp[i] = max(dp[i],1+dp[j]); } } lis = max(lis,dp[i]); } cout << n - lis << 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...