Submission #127386

#TimeUsernameProblemLanguageResultExecution timeMemory
127386impriStudentsko (COCI14_studentsko)C++14
0 / 100
50 ms536 KiB
#include<bits/stdc++.h> using namespace std; int memo[10000]; int get(int arr[],int len,int cur){ if(memo[cur]) return memo[cur]; int result=1; if(len-1==cur) return 1; for(int i=cur+1;i<len;i++){ if(arr[i]>arr[cur]) result=max(result,1+get(arr,len,i)); } return memo[cur]=result; } int main(void){ios_base::sync_with_stdio(false);cin.tie(0); int n,k; vector<pair<int,int> >skills; int newarr[5000]; cin >> n >> k; for(int i=0;i<n;i++){ int a; cin >> a; skills.push_back(make_pair(a,i)); } sort(skills.begin(),skills.end()); for(int i=0;i<n;i++){ newarr[skills[i].second]=i/k; } int result=0; for(int i=0;i<n;i++){ result=max(result,get(newarr,n,i)); } cout << n-result; }
#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...