artemgf

Плитка шоколада

Nov 9th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5. #include <set>
  6. #include <algorithm>
  7. #include <vector>
  8. #include <stdio.h>
  9. #include <cmath>
  10. #include <math.h>
  11. #include <queue>
  12. #include <stack>
  13. #include <climits>
  14. #include <deque>
  15. #include <ctime>
  16.  
  17. using namespace std;
  18.  
  19. typedef long long ll;
  20. typedef unsigned long long ull;
  21. typedef unsigned int ui;
  22.  
  23. #define mh() make_heap()
  24. #define poph() pop_heap()
  25. #define pushh() push_heap()
  26. #define sor(n) n.begin(), n.end()
  27.  
  28. vector<pair<int, int>>list;
  29.  
  30. int main()
  31. {
  32.     long long n;
  33.     cin >> n;
  34.     string h;
  35.     ll prom1, prom2;
  36.     for (int i = 1; i <= n; i++)
  37.     {
  38.         cin >> h;
  39.         cin >> prom1;
  40.         if (prom1 == 1)
  41.         {
  42.             cin >> prom2;
  43.             list.push_back({ prom1,prom2 });
  44.         }
  45.         else
  46.         {
  47.             list.push_back({ prom1,0 });
  48.         }
  49.     }
  50.    
  51.     ll las = 0;
  52.     ll now = 0;
  53.     ll sc = 0; 
  54.     ll max = 0;
  55.     ll min = 0;
  56.     ll promn = 1;
  57.     for (int i = list.size()-1; i >= 0; i--)
  58.     {
  59.         if (list[i].first == 1)
  60.         {
  61.             las = now;
  62.             now = list[i].second;
  63.             if (now < las)
  64.             {
  65.                 cout << "NO";
  66.                 return 0;
  67.             }
  68.             min += now;
  69.             max += now + sc*now;
  70.             promn = now;
  71.             sc = 0;
  72.         }
  73.         else
  74.         {
  75.             min += promn;
  76.             sc++;
  77.         }
  78.     }
  79.  
  80.     max += sc * 10000;
  81.     if (max >= 10000 && min <= 10000)
  82.         cout << "YES";
  83.     else
  84.         cout << "NO";
  85.     system("pause");
  86.     return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment