Submission #960239

#TimeUsernameProblemLanguageResultExecution timeMemory
960239khangrlStudentsko (COCI14_studentsko)C++14
100 / 100
2 ms856 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; vector <pair <int, int> > v, sub; cin>>n>>k; for(int i=1; i<=n; i++){ int a; cin>>a; v.pb({a, i}); } sort(v.begin(), v.end()); int y=1, i=1; for(auto x:v){ sub.pb({x.ss, y}); if(i%k==0){ y++; } i++; } sort(sub.begin(), sub.end()); vector <int> ans; vector <int> ::iterator itr; for(auto x:sub){ itr=upper_bound(ans.begin(), ans.end(), x.ss); if(itr==ans.end()){ ans.pb(x.ss); } else{ *itr=x.ss; } } cout<<n-ans.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...