SHARE
TWEET

Untitled

a guest Oct 14th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*#pragma GCC optimize("Ofast,no-stack-protector")
  2. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  3. #pragma GCC optimize("unroll-loops")
  4. #pragma GCC optimize("fast-math")*/
  5. #include <iostream>
  6. #include <complex>
  7. #include <vector>
  8. #include <string>
  9. #include <algorithm>
  10. #include <cstdio>
  11. #include <numeric>
  12. #include <cstring>
  13. #include <ctime>
  14. #include <cstdlib>
  15. #include <set>
  16. #include <map>
  17. #include <unordered_map>
  18. #include <unordered_set>
  19. #include <list>
  20. #include <cmath>
  21. #include <bitset>
  22. #include <cassert>
  23. #include <queue>
  24. #include <stack>
  25. #include <deque>
  26. #include <random>
  27.  
  28. using namespace std;
  29.  
  30. #define pb push_back
  31. #define all(x) x.begin(), x.end()
  32. #define rall(x) x.rbegin(), x.rend()
  33. #define Str(x) to_string(x)
  34. #define len(s) (int)s.size()
  35. #define int long long
  36. typedef long long ll;
  37. typedef long double lld;
  38. typedef string str;
  39. typedef unsigned long long ull;
  40.  
  41. main() {
  42.     ios_base::sync_with_stdio(false);
  43.     cin.tie(NULL);
  44.     cout.tie(NULL);
  45. #ifdef LOCAL
  46.     freopen("input.txt", "r", stdin);
  47.     freopen("output.txt", "w", stdout);
  48. #endif
  49.     int t;
  50.     cin >> t;
  51.     while (t--) {
  52.         int n;
  53.         cin >> n;
  54.         vector<pair<pair<int, int> , int> > v;
  55.         for (int i = 0; i < n; i++) {
  56.             int x, y, z;
  57.             cin >> x >> y >> z;
  58.             v.pb({{x, y}, z});
  59.         }
  60.         sort(all(v));
  61.         int start = -1e9;
  62.         bool ans = true;
  63.         for (auto it : v) {
  64.             start = max(start + it.second, it.first.first + it.second);
  65.             if (start > it.first.second)
  66.             {
  67.                 ans = false;
  68.                 break;
  69.             }
  70.         }
  71.         cout << ans << endl;
  72.     }
  73.  
  74.     return 0;
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top