Guest User

Untitled

a guest
Nov 6th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. //#pragma comment(linker, "/STACK:16777216")
  2. #include <fstream>
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <string>
  6. #include <iomanip>
  7. #include <complex>
  8. #include <math.h>
  9. #include <cmath>
  10. #include <cstring>
  11. #include <cstdio>
  12. #include <cassert>
  13. #include <set>
  14. #include <vector>
  15. #include <map>
  16. #include <queue>
  17. #include <deque>
  18. #include <stack>
  19. #include <algorithm>
  20. #include <bitset>
  21. #include <list>
  22.  
  23. using namespace std;
  24.  
  25. #define x first
  26. #define y second
  27. #define pb push_back
  28. #define mp make_pair
  29. #define all(a) (a).begin(), (a).end()
  30. #define rall(a) (a).rbegin(), (a).rend()
  31. #define sz(a) int((a).size())
  32. #define sqr(x) ((x)*(x))
  33. #define forn(i, n) for (int i = 0; i < int(n); i++)
  34. #define foreach(i, a) for (auto i : a)
  35. #define NAME "library"
  36. #define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
  37. #define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
  38.  
  39. #define y0 sdkfaslhagaklsldk
  40. #define y1 aasdfasdfasdf
  41. #define yn askfhwqriuperikldjk
  42. #define j1 assdgsdgasghsf
  43. #define tm sdfjahlfasfh
  44. #define lr asgasgashqt
  45. #define free afdshjioeyqtw
  46. #define next qpowityqwopqw
  47. #define prev paoueoroill
  48.  
  49. typedef unsigned int unt;
  50. typedef long long ll;
  51. typedef unsigned long long ull;
  52. typedef long double ld;
  53. typedef pair < int, int > pii;
  54. typedef pair < ll, ll > pll;
  55.  
  56. const ll MOD = 1e9 + 7;
  57. const int INF = 1e9 + 1;
  58. const ll INF64 = 2e18;
  59. const ll T = 23525;
  60. const ll MD = 1623623452;
  61. const int N = 300011;
  62. const int M = 20010;
  63.  
  64. int n, s[N], f[N], c[N];
  65. vector < pii > a;
  66. set < pii > s1, s2;
  67.  
  68. void er() {
  69. cout << "NO";
  70. exit(0);
  71. }
  72.  
  73. int main() {
  74. FREOPEN;
  75. ios::sync_with_stdio(0);
  76. cin >> n;
  77. for (int i = 1; i <= n; i++) {
  78. cin >> s[i] >> f[i] >> c[i];
  79. a.pb(mp(s[i], i));
  80. a.pb(mp(s[i] + c[i], -1));
  81. a.pb(mp(f[i], -1));
  82. }
  83. sort(all(a));
  84. forn(i, sz(a)) {
  85. int j = i;
  86. while (j < sz(a) && a[i].x == a[j].x) {
  87. if (a[j].y > 0)
  88. s1.insert(mp(a[j].x + c[a[j].y], a[j].y));
  89. j++;
  90. }
  91. i = j - 1;
  92. while (!s1.empty() && s1.begin()->x == a[i].x) {
  93. int v = s1.begin()->y;
  94. s1.erase(s1.begin());
  95. s2.insert(mp(f[v], v));
  96. }
  97. int dd = a[i].x;
  98. while (!s2.empty() && (i == sz(a) - 1 || a[i + 1].x > dd)) {
  99. if (s2.begin()->x < dd)
  100. er();
  101. s2.erase(s2.begin());
  102. dd++;
  103. }
  104. }
  105. cout << "YES";
  106. return 0;
  107. }
  108.  
  109.  
  110.  
  111.  
  112. /*
  113.  
  114.  
  115.  
  116. */
Advertisement
Add Comment
Please, Sign In to add comment