Advertisement
Malinovsky239

Untitled

Nov 21st, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int a[105], n;
  8.  
  9. bool ans(int pos) {
  10.     if (pos > n)
  11.         return true;
  12.     if (a[pos] == 1)
  13.         return (!ans(pos + 1));
  14.     return true;
  15. }
  16.  
  17. int main() {
  18.     freopen("smallnim.in", "r", stdin);
  19.     freopen("smallnim.out", "w", stdout);
  20.  
  21.     cin >> n;
  22.     for (int i = 0; i < n; i++)
  23.         cin >> a[i];
  24.  
  25.     sort(a, a + n);
  26.  
  27.     if (ans(0))
  28.         cout << "YES\n" << (a[0] - 1 > 0 ? a[0] - 1: 1);
  29.     else
  30.         cout << "NO\n";
  31.                
  32.     return 0;
  33. }
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement