fork download
  1. #include <iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector<int>arr={2,5,2,5,2,5,1,1};
  7. int d=5,m=2,n=arr.size();
  8. int count=0;
  9. for(int i=0;i<n;i++){
  10. int d_count=0;
  11. for(int j=i;j<n;j++){
  12. if(arr[j]==d){
  13. d_count++;
  14. }
  15. if(d_count==m){
  16. count++;
  17. }
  18. }
  19. }
  20. cout<<count;
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
10