Advertisement
Guest User

A - Bath Temperature

a guest
Aug 22nd, 2017
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n, x;  
  7.     cin >> n >> x;
  8.     int mn = 101;
  9.     int mx = -1;
  10.     for(int i = 0; i < n; i++) {
  11.         int a;
  12.         cin >> a;
  13.         if(a == x) {
  14.             cout << 1 << endl;
  15.             return 0;
  16.         }
  17.         mn = min(mn, a);
  18.         mx = max(mx, a);
  19.     }
  20.     cout << ((x > mn and x < mx) ? 2 : -1) << endl;
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement