Advertisement
Dennnhhhickk

Untitled

Apr 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. struct tt{
  6. ll fas, in, out, num;
  7. };
  8. deque <tt> a;
  9. int push1(tt temp){
  10. tt temp1, temp2;
  11. temp1 = a.back();
  12. a.pop_back();
  13. temp2 = a.back();
  14. if (temp1.fas == temp2.fas && temp.fas != temp1.fas)
  15. while (temp1.fas == temp2.fas){
  16. a.pop_back();
  17. if (a.size())
  18. temp2 = a.back();
  19. else
  20. break;
  21. }
  22. else
  23. a.push_back(temp1);
  24. a.push_back(temp);
  25. //cout << "1" << endl;
  26. return 0;
  27. }
  28. int push(tt temp){
  29. if (a.size() > 1)
  30. push1(temp);
  31. else
  32. a.push_back(temp);
  33. return 0;
  34. }
  35.  
  36. int main()
  37. {
  38. ifstream in("hats.in");
  39. ofstream out("hats.out");
  40. ll n, ttime = -100;
  41. in >> n;
  42. tt temp;
  43. bool bol;
  44. for (int i = 0; i < n; i++){
  45. in >> temp.fas >> temp.in >> temp.out;
  46. temp.num = i + 1;
  47. if (ttime >= temp.in){
  48. push(temp);
  49. }
  50. else{
  51. if (a.size()){
  52. out << a.front().num << " ";
  53. if (ttime > a.front().in)
  54. ttime += a.front().out;
  55. else
  56. ttime = a.front().in + a.front().out;
  57. a.pop_front();
  58. push(temp);
  59. }
  60. else{
  61. out << temp.num << " ";
  62. if (ttime > temp.in)
  63. ttime += temp.out;
  64. else
  65. ttime = temp.in + temp.out;
  66. }
  67. }
  68. }
  69. while (a.size()){
  70. out << a.front().num << " ";
  71. a.pop_front();
  72. }
  73. return 0;
  74. }
  75.  
  76.  
  77. /*
  78. 6
  79. 1 2 3
  80. 1 3 3
  81. 1 4 3
  82. 1 5 3
  83. 1 6 3
  84. 2 7 3
  85.  
  86. 10
  87. 1 1 1
  88. 2 5 100
  89. 2 6 1
  90. 2 7 1
  91. 2 8 1
  92. 1 9 1
  93. 2 10 1
  94. 2 11 1
  95. 1 12 1
  96. 2 13 2
  97.  
  98.  
  99. 20
  100. 1 3 7
  101. 2 8 19
  102. 2 15 4
  103. 1 25 10
  104. 2 26 9
  105. 1 28 11
  106. 2 41 12
  107. 1 43 20
  108. 1 44 4
  109. 1 51 16
  110. 2 53 7
  111. 1 54 19
  112. 2 56 2
  113. 1 60 19
  114. 1 66 1
  115. 1 70 3
  116. 2 72 14
  117. 2 83 10
  118. 2 86 2
  119. 1 94 1
  120.  
  121. 1 2 3 4 5 6 12 13 17 20
  122.  
  123. 6
  124. 1 1 9
  125. 1 2 1
  126. 2 3 1
  127. 2 4 1
  128. 1 5 1
  129. 3 6 1
  130.  
  131. 6
  132. 1 1 9
  133. 1 2 1
  134. 2 3 1
  135. 2 4 1
  136. 3 5 1
  137. 3 6 1
  138.  
  139. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement