fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. bool chk = 0, worse = 0;
  6. int n, k, t = 0, cnt = 0;
  7. cin >> n >> k;
  8. string s, pass;
  9. vector<string> myList;
  10.  
  11. for (int i = 0; i < n; i++) {
  12. cin >> s;
  13. myList.push_back(s);
  14. }
  15. cin >> pass;
  16.  
  17. sort(myList.begin(), myList.end(),
  18. [](const string& val1, const string& val2) {
  19. return val1.size() < val2.size();
  20. });
  21.  
  22. for (int i = 0; i < n; i++) {
  23. if (cnt == k)
  24. cnt = 0;
  25.  
  26. if (cnt == 0 && i >= k - 1)
  27. t += 5;
  28. t++;
  29.  
  30. if (pass.length() == myList[i].length() && chk == false) {
  31. cout << t << " ";
  32. chk = true;
  33.  
  34. }
  35.  
  36. if (pass.length() < myList[i].length() && worse == false) {
  37. cout << t;
  38. worse = true;
  39.  
  40. }
  41.  
  42. cnt++;
  43.  
  44. }
  45. if (myList[n - 1].length() == pass.length()) {
  46. cout << t;
  47.  
  48. }
  49.  
  50. }
  51.  
  52.  
Success #stdin #stdout 0s 15248KB
stdin
4 100
11
22
1
2
22
out
stdout
3 4