fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <iomanip>
  9.  
  10. using namespace std;
  11. #define all(v) (v.begin()), (v.end())
  12.  
  13. void fast_io(){
  14. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  15. }
  16.  
  17. int main()
  18. {
  19. fast_io();
  20. int n, k;
  21. cin >> n >> k;
  22. int participants[n];
  23. int count = 0;
  24. for (int i = 0; i < n; i++){
  25. cin >> participants[i];
  26. }
  27. for (int i = 0; i < n; i++){
  28. if (participants[i] > 0 && participants[i] >= participants[k]){
  29. count++;
  30. }
  31. }
  32. cout << count << endl;
  33. }
Success #stdin #stdout 0.01s 5268KB
stdin
8 5
10 9 8 7 7 7 5 5
stdout
6