Submission #1108170

#TimeUsernameProblemLanguageResultExecution timeMemory
1108170overwatch9Studentsko (COCI14_studentsko)C++17
100 / 100
6 ms848 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector <int> nums(n), id(n); vector <int> nums2(n); map <int, int> pos; for (int i = 0; i < n; i++) { cin >> nums[i]; nums2[i] = nums[i]; pos[nums[i]] = i; } sort(nums2.begin(), nums2.end()); for (int i = 0, pt = 0; i < n; i++) { if (i % k == 0) pt++; id[pos[nums2[i]]] = pt; } vector <int> dp; for (int i = 0; i < n; i++) { auto it = upper_bound(dp.begin(), dp.end(), id[i]); if (it == dp.end()) dp.push_back(id[i]); else *it = id[i]; } cout << n - (int)dp.size() << '\n'; }
#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...