Submission #276922

#TimeUsernameProblemLanguageResultExecution timeMemory
276922wutwereStudentsko (COCI14_studentsko)C++17
100 / 100
162 ms512 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n ; i++) cin >> v[i]; vector<int> sortedv = v; sort(sortedv.begin(), sortedv.end()); for (int i = 0; i < n / k; i++) { set<int> s; for (int j = 0; j < k; j++) { s.insert(sortedv[i * k + j]); } int p = 0; for (int j = 0; j < n; j++) { if (s.count(v[j])) { v[j] = sortedv[i * k + p]; p++; } } } vector<int> dp(n, 1); int longest = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (v[i] > v[j]) { dp[i] = max(dp[i], dp[j] + 1); } } longest = max(longest, dp[i]); } cout << n - longest; }
#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...