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