Submission #440104

# Submission time Handle Problem Language Result Execution time Memory
440104 2021-07-01T15:28:58 Z gromperen Studentsko (COCI14_studentsko) C++17
100 / 100
2 ms 444 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, k; cin >> n >> k;
	vector<int> v(n), a(n);
	vector<pair<int,int>> b(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		b[i] = {v[i], i};
	}
	sort(b.begin(), b.end());
	int team = 0;
	for (int i = 0; i < n; ++i) {
		if (i % k == 0) team++;
		a[b[i].second] = team;
	}
	//for (int i = 0; i < n; ++i) {
		//cout << a[i] << " ";
	//}
	//cout << endl;
	vector<int> lis;
	for (int i = 0; i < n; ++i) {
		auto it = upper_bound(lis.begin(), lis.end(), a[i]);
		if (it != lis.end()) *it = a[i];
		else lis.push_back(a[i]);
	}
	//cout << lis.size() << "\n";
	cout << n - lis.size() << "\n";

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 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 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct