Submission #499154

#TimeUsernameProblemLanguageResultExecution timeMemory
499154LouayFarahStudentsko (COCI14_studentsko)C++14
10 / 100
46 ms520 KiB
#include "bits/stdc++.h" using namespace std; #define endl "\n" #define ll long long int #define pb push_back #define mp make_pair #define fi first #define se second const long long MOD = 1e9+7; const long long INF = 1e18; int nx[4] = {0, 0, -1, 1}; int ny[4] = {1, -1, 0, 0}; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n, k; cin >> n >> k; vector<pair<ll, ll>> v; for(int i = 0; i<n; i++) { ll x; cin >> x; v.pb(mp(x, i)); } sort(v.begin(), v.end()); vector<ll> arr(n, 0); for(int i = 0; i<n; i++) { arr[v[i].se] = i/k; } vector<ll> dp(n, 0); for(int i = 0; i<n; i++) { dp[i] = 1; for(int j = 0; j<i; j++) { if(arr[j]<=arr[i]) dp[i] = max(dp[i], dp[j] +1); } } cout << n-dp[n-1] << endl; return 0; }
#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...