#include <bits/stdc++.h> using namespace std; auto main() -> int { int usersC, shirtsC; cin >> usersC >> shirtsC; vector<int> scores(usersC); for(int i = 0; i < usersC; i ++){ cin >> scores[i]; } sort(scores.begin(), scores.end(), [](int a, int b){ return a > b; }); int index = shirtsC - 1; while(index != scores.size() && scores[index - 1] != scores[index]){ index++; shirtsC ++; } cout<<shirtsC; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <bits/stdc++.h> using namespace std; auto main() -> int { int usersC, shirtsC; cin >> usersC >> shirtsC; vector<int> scores(usersC); for(int i = 0; i < usersC; i ++){ cin >> scores[i]; } sort(scores.begin(), scores.end(), [](int a, int b){ return a > b; }); int index = shirtsC - 1; while(index != scores.size() && scores[index - 1] != scores[index]){ index++; shirtsC ++; } cout<<shirtsC; } |