Submission #81925

#TimeUsernameProblemLanguageResultExecution timeMemory
81925heonStudentsko (COCI14_studentsko)C++11
100 / 100
7 ms1468 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,k; cin >> n >> k; vector <int> v(n); vector <int> p; for(int i = 0; i < n; i++){ cin >> v[i]; p.push_back(v[i]); } sort(p.begin(), p.end()); map <int, int> mp; for(int i = 0; i < n; i++){ mp[p[i]] = i/k; } multiset <int> mst; for(int i = 0; i < n; i++){ int value = mp[v[i]]; mst.insert(value); auto it = mst.upper_bound(value); if(it != mst.end()) mst.erase(mst.find(*it)); } cout << n - mst.size(); }
#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...