Submission #440104

#TimeUsernameProblemLanguageResultExecution timeMemory
440104gromperenStudentsko (COCI14_studentsko)C++17
100 / 100
2 ms444 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<int> v(n), a(n); vector<pair<int,int>> b(n); for (int i = 0; i < n; ++i) { cin >> v[i]; b[i] = {v[i], i}; } sort(b.begin(), b.end()); int team = 0; for (int i = 0; i < n; ++i) { if (i % k == 0) team++; a[b[i].second] = team; } //for (int i = 0; i < n; ++i) { //cout << a[i] << " "; //} //cout << endl; vector<int> lis; for (int i = 0; i < n; ++i) { auto it = upper_bound(lis.begin(), lis.end(), a[i]); if (it != lis.end()) *it = a[i]; else lis.push_back(a[i]); } //cout << lis.size() << "\n"; cout << n - lis.size() << "\n"; 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...