SHARE
TWEET

A - Bath Temperature

a guest Aug 22nd, 2017 163 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top