Advertisement
Dennnhhhickk

Untitled

Apr 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 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. push(temp);
  62. out << a.front().num << " ";
  63. if (ttime > a.front().in)
  64. ttime += a.front().out;
  65. else
  66. ttime = a.front().in + a.front().out;
  67. a.pop_front();
  68. }
  69. }
  70. }
  71. while (a.size()){
  72. out << a.front().num << " ";
  73. a.pop_front();
  74. }
  75. return 0;
  76. }
  77.  
  78.  
  79. /*
  80. 10
  81. 1 1 1
  82. 2 5 100
  83. 2 6 1
  84. 2 7 1
  85. 2 8 1
  86. 1 9 1
  87. 2 10 1
  88. 2 11 1
  89. 1 12 1
  90. 2 13 2
  91.  
  92.  
  93. 20
  94. 1 3 7
  95. 2 8 19
  96. 2 15 4
  97. 1 25 10
  98. 2 26 9
  99. 1 28 11
  100. 2 41 12
  101. 1 43 20
  102. 1 44 4
  103. 1 51 16
  104. 2 53 7
  105. 1 54 19
  106. 2 56 2
  107. 1 60 19
  108. 1 66 1
  109. 1 70 3
  110. 2 72 14
  111. 2 83 10
  112. 2 86 2
  113. 1 94 1
  114.  
  115. 1 2 3 4 5 6 12 13 17 20
  116.  
  117. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement