SHARE
TWEET

Untitled

lalalalalalalaalalla Oct 14th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <numeric>
  12. #include <map>
  13. #include <bitset>
  14. #include <set>
  15. #include <stack>
  16. #include <queue>
  17. #include <unordered_set>
  18.  
  19.  
  20. //#pragma GCC optimize("Ofast,no-stack-protector")
  21. //#pragma GCC optimize("O3")
  22. //#pragma GCC target("avx2")
  23. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  24. //#pragma GCC optimize("unroll-loops")
  25. //#pragma GCC optimize("fast-math")
  26. //#pragma GCC optimize("section-anchors")
  27. //#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
  28. //#pragma GCC optimize("vpt")
  29. //#pragma GCC optimize("rename-registers")
  30. //#pragma GCC optimize("move-loop-invariants")
  31. //#pragma GCC optimize("unswitch-loops")
  32. //#pragma GCC optimize("function-sections")
  33. //#pragma GCC optimize("data-sections")
  34. //#pragma GCC optimize("branch-target-load-optimize")
  35. //#pragma GCC optimize("branch-target-load-optimize2")
  36. //#pragma GCC optimize("btr-bb-exclusive")
  37. //#pragma GCC optimize("O0")
  38.  
  39.  
  40. #define int long long
  41. #define ll long long
  42. #define ull unsigned long long
  43. #define all(a) a.begin(), a.end()
  44. #define pii pair<int, int>
  45. #define pb push_back
  46. #define ld long double
  47.  
  48.  
  49. using namespace std;
  50.  
  51. const int INF = 1e18;
  52. //const int mod = 2600000069;
  53. //const int p = 179;
  54.  
  55. bool comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  56.     if (a.first.first < b.first.first) return 1;
  57.     else if (a.first.first > b.first.first) return 0;
  58.     if (a.first.second < b.first.second) return 1;
  59.     else if (a.first.second > b.first.second) return 0;
  60.     if (a.second > b.second) return 0;
  61.     return 1;
  62. }
  63.  
  64. signed main() {
  65.     ios_base::sync_with_stdio(0);
  66.     cin.tie(0);
  67.     cout.tie(0);
  68.     int q;
  69.     cin >> q;
  70.     while(q--) {
  71.         int n;
  72.         cin >> n;
  73.         vector<pair<pair<int, int>, int>> a(n);
  74.         for (int i = 0; i < n; i++) {
  75.             cin >> a[i].first.first >> a[i].first.second >> a[i].second;
  76.         }
  77.         sort(all(a), comp);
  78.         vector<int> dp(n);
  79.         dp[0] = a[0].first.first + a[0].second;
  80.         bool ok = 0;
  81.         for (int i = 1; i < n; i++) {
  82.             if (ok) break;
  83.             if (max(dp[i-1], a[i].first.first) + a[i].second > a[i].first.second) {
  84.                 cout << 0 << "\n";
  85.                 ok = 1;
  86.             }
  87.         }
  88.         if (!ok) cout << 1 << "\n";
  89.     }
  90. }
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