Submission #485909

# Submission time Handle Problem Language Result Execution time Memory
485909 2021-11-09T16:25:35 Z groupATSU Studentsko (COCI14_studentsko) C++14
100 / 100
47 ms 412 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=1e9;
const int maxn=100;
const ll mod=1e9+7;
void solve(){
	int a,k;
	cin>>a>>k;
	vector <pair<int,int>> b(a);
	for(int i=0;i<a;i++){
		cin>>b[i].first;
		b[i].second=i;
	}
	sort(b.begin(),b.end());
	vector <int> h(a);
	for(int i=0;i<a;i++){
		h[b[i].second]=i/k;	
	}                      
	vector <int> dp(a+5);
	int ans=0;
	for(int i=0;i<a;i++){
		dp[i]=1;
		for(int t=0;t<i;t++){
			if(h[i]>=h[t]){
				dp[i]=max(dp[i],dp[t]+1);
			}
		}
		ans=max(ans,dp[i]);
	}
	cout<<a-ans;
}
int main(){
	//ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int t=1;
   	//cin>>t;
    while(t--){
        solve();
        cout<<'\n';
    }


}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 404 KB Output is correct
2 Correct 29 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 388 KB Output is correct
2 Correct 38 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 332 KB Output is correct
2 Correct 23 ms 412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 332 KB Output is correct
2 Correct 36 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 332 KB Output is correct
2 Correct 47 ms 412 KB Output is correct