artemgf

Куча орехов

Apr 15th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <set>
  6. #include <map>
  7. #include <algorithm>
  8. #include <string>
  9. #include <math.h>
  10. #include <vector>
  11. #include <cmath>
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17.     long long min = 10, n, prom;
  18.     set <int> is, hun;
  19.     bool d=true;
  20.     string prom2;
  21.  
  22.     cin >> n;
  23.  
  24.     for (int i = 1; i <= n; i++)
  25.     {
  26.         cin >> prom >> prom2;
  27.         if (prom2 == "hungry")
  28.         {
  29.             bool what = true;
  30.             for (auto i = is.begin(); i != is.end(); i++)
  31.             {
  32.                 if (prom >= *i)
  33.                     what = false;
  34.             }
  35.             if (what == true)
  36.                 hun.insert(prom);
  37.             else
  38.             {
  39.                 d = false;
  40.             }
  41.         }
  42.         else
  43.         {
  44.             bool what = true;
  45.             for (auto i = hun.begin(); i != hun.end(); i++)
  46.             {
  47.                 if (prom <= *i)
  48.                     what = false;
  49.             }
  50.             if (min > prom)
  51.                 min = prom;
  52.             if (what == true)
  53.                 is.insert(prom);
  54.             else
  55.             {
  56.                 d = false;
  57.             }
  58.         }
  59.     }
  60.  
  61.     if (d == true)
  62.         if (min <= 2)
  63.             cout << "Inconsistent";
  64.         else
  65.             cout << min;
  66.     else
  67.         cout << "Inconsistent";
  68.  
  69.     system("pause");
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment