fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. ios::sync_with_stdio(false);
  7. cin.tie(0);
  8. int n, k;
  9. cin >> n >> k;
  10. int a[n + 5];
  11. for(int i = 0; i < n; i++) {
  12. cin >> a[i];
  13. }
  14. int ans = 0;
  15. int pos = -1;
  16. for(int i = 0; i < n; i++) {
  17. if(k < a[i]) break;
  18. if(k >= a[i]) ans++, pos = i;
  19. }
  20. for(int i = n - 1; i >= 0; i--) {
  21. if(k < a[i]) break;
  22. if(k >= a[i]) ans++;
  23. }
  24. cout << ans << "\n";
  25. return 0;
  26. }
Success #stdin #stdout 0s 4396KB
stdin
6 6
7 1 1 1 1 1
stdout
5