fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(){
  5. int n; double x;
  6. cin >> n >> x;
  7. double am = 0, duong = 0;
  8. int begin = 0, end = 0;
  9. for (int i = 1; i <=n ; i++ ){
  10. double a;
  11. cin >> a;
  12. if (a < 0) {
  13. if (am == 0) am = a;
  14. }
  15. else duong = a;
  16. if (a == x ) {
  17. if (begin == 0) begin = i;
  18. end = i;
  19. }
  20.  
  21. }
  22.  
  23. cout << fixed << setprecision(2) << am << ' ' << duong << endl;
  24. cout << begin << ' ' << end;
  25. }
  26. int main(){
  27. ios_base::sync_with_stdio(0);
  28. cin.tie(0); cout.tie(0);
  29. solve();
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
0.00 0.00
0 0