Submission #89384

#TimeUsernameProblemLanguageResultExecution timeMemory
89384alipashaStudentsko (COCI14_studentsko)C++14
100 / 100
51 ms944 KiB
#include<bits/stdc++.h> using namespace std; int test; int n; int k; int dp[5005]; pair<int,int> B[5005]; int A[5005]; int main(){ cin >> n; cin >> k; for(int i=0; i<n; i++) { int v; cin >> v; B[i]={v,i}; } sort(B,B+n); int group=0; int cnt=0; for(int i=0; i<n; i++) { A[B[i].second]=group; cnt++; if(cnt==k) { cnt=0; group++; } } dp[0]=1; int maxi; int ans=0; for(int i=1; i<n; i++) { maxi=i; for(int j=0; j<i; j++) { if(A[j]<=A[i] && dp[j]>dp[maxi]) { maxi=j; } } dp[i]=dp[maxi]+1; ans=max(ans,dp[i]); } cout << 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...