#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int coders;
int tshirts;
cin >> coders >> tshirts;
vector<int> results(coders);
while (coders--) {
cin >> results[coders];
}
sort(results.begin(), results.end());
int ptr = results.size() - tshirts;
while (ptr > 0 && results[ptr - 1] == results[ptr]) {
tshirts++;
ptr--;
}
cout << tshirts;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int coders; int tshirts; cin >> coders >> tshirts; vector<int> results(coders); while (coders--) { cin >> results[coders]; } sort(results.begin(), results.end()); int ptr = results.size() - tshirts; while (ptr > 0 && results[ptr - 1] == results[ptr]) { tshirts++; ptr--; } cout << tshirts; } |
English