Submission #918777

#TimeUsernameProblemLanguageResultExecution timeMemory
918777vjudge1Studentsko (COCI14_studentsko)C++17
0 / 100
17 ms65536 KiB
#include<bits/stdc++.h> using namespace std; #define ll int #define pii pair<ll,ll> #define pb push_back #define fi first #define se second const ll N = 5003; ll n,k; pii q[N]; ll a[N],memo[N][N]; ll dp(ll x, ll y) { if(x == n+1) return 0; ll temp = memo[x][y]; if(temp != -1) return temp; temp = dp(x+1,y); if(a[x] >= y) { temp = max(temp,dp(x+1,a[x])+1); } return memo[x][y] = temp; } int main() { memset(memo,-1,sizeof(memo)); cin >> n >> k; for(int i=1; i<=n; i++) { cin >> q[i].fi; q[i].se = i; } sort(q+1,q+n+1); for(int i=1; i<=n; i++) { a[q[i].se] = (i-1)/k + 1; } cout << n - dp(1,0) << 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...