Submission #1116654

#TimeUsernameProblemLanguageResultExecution timeMemory
111665412345678Studentsko (COCI14_studentsko)C++17
100 / 100
31 ms848 KiB
#include <bits/stdc++.h> using namespace std; const int nx=5e3+5; int n, k, v[nx], t, res=INT_MAX, dp[nx]; map<int, int> mp; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>k; for (int i=1; i<=n; i++) cin>>v[i], mp[v[i]]=0; for (auto &[x, y]:mp) y=(t/k)+1, t++; for (int i=1; i<=n; i++) v[i]=mp[v[i]]; for (int i=1; i<=n; i++) { dp[i]=1; for (int j=1; j<i; j++) if (v[j]<=v[i]) dp[i]=max(dp[i], dp[j]+1); res=min(res, n-dp[i]); } cout<<res; }
#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...