Submission #960239

# Submission time Handle Problem Language Result Execution time Memory
960239 2024-04-10T01:24:34 Z khangrl Studentsko (COCI14_studentsko) C++14
100 / 100
2 ms 856 KB
#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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct