Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*#pragma GCC optimize("Ofast,no-stack-protector")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- #pragma GCC optimize("unroll-loops")
- #pragma GCC optimize("fast-math")*/
- #include <iostream>
- #include <complex>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <cstdio>
- #include <numeric>
- #include <cstring>
- #include <ctime>
- #include <cstdlib>
- #include <set>
- #include <map>
- #include <unordered_map>
- #include <unordered_set>
- #include <list>
- #include <cmath>
- #include <bitset>
- #include <cassert>
- #include <queue>
- #include <stack>
- #include <deque>
- #include <random>
- using namespace std;
- #define pb push_back
- #define all(x) x.begin(), x.end()
- #define rall(x) x.rbegin(), x.rend()
- #define Str(x) to_string(x)
- #define len(s) (int)s.size()
- #define int long long
- typedef long long ll;
- typedef long double lld;
- typedef string str;
- typedef unsigned long long ull;
- main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int t;
- cin >> t;
- while (t--) {
- int n;
- cin >> n;
- vector<pair<pair<int, int> , int> > v;
- for (int i = 0; i < n; i++) {
- int x, y, z;
- cin >> x >> y >> z;
- v.pb({{x, y}, z});
- }
- sort(all(v));
- int start = -1e9;
- bool ans = true;
- for (auto it : v) {
- start = max(start + it.second, it.first.first + it.second);
- if (start > it.first.second)
- {
- ans = false;
- break;
- }
- }
- cout << ans << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement