Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <stdio.h>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <deque>
- #include <ctime>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- #define mh() make_heap()
- #define poph() pop_heap()
- #define pushh() push_heap()
- #define sor(n) n.begin(), n.end()
- vector<pair<int, int>>list;
- int main()
- {
- long long n;
- cin >> n;
- string h;
- ll prom1, prom2;
- for (int i = 1; i <= n; i++)
- {
- cin >> h;
- cin >> prom1;
- if (prom1 == 1)
- {
- cin >> prom2;
- list.push_back({ prom1,prom2 });
- }
- else
- {
- list.push_back({ prom1,0 });
- }
- }
- ll las = 0;
- ll now = 0;
- ll sc = 0;
- ll max = 0;
- ll min = 0;
- ll promn = 1;
- for (int i = list.size()-1; i >= 0; i--)
- {
- if (list[i].first == 1)
- {
- las = now;
- now = list[i].second;
- if (now < las)
- {
- cout << "NO";
- return 0;
- }
- min += now;
- max += now + sc*now;
- promn = now;
- sc = 0;
- }
- else
- {
- min += promn;
- sc++;
- }
- }
- max += sc * 10000;
- if (max >= 10000 && min <= 10000)
- cout << "YES";
- else
- cout << "NO";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment