fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.  
  6. int n,k,count;
  7.  
  8. cin>>n>>k;
  9. count=k;
  10. int A[n];
  11. for(int i=0;i<n;i++)
  12. {
  13. cin>>A[i];
  14. }
  15. for(int i=0;i<n;i++)
  16. {
  17. if(A[i]!=0&&A[i]>=A[k-1])
  18. {
  19. count++;
  20. }
  21. }
  22. cout<<count;
  23. return 0;
  24.  
  25. }
Success #stdin #stdout 0s 15232KB
stdin
4 0
0 0 0 0
stdout
Standard output is empty