Advertisement
Dennnhhhickk

Untitled

Apr 14th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. struct tt{
  6. ll f, in, out, num;
  7. };
  8. deque <tt> a;
  9. int push(tt temp);
  10. ifstream in("hats.in");
  11. ofstream out("hats.out");
  12.  
  13. int main()
  14. {
  15. ll n, m, ttime;
  16. tt temp;
  17. in >> n;
  18. in >> temp.f >> temp.in >> temp.out;
  19. out << "1 ";
  20. ttime = temp.in + temp.out;
  21. for (int i = 1; i < n; i++){
  22. in >> temp.f >> temp.in >> temp.out;
  23. temp.num = i;
  24. if (a.size() <= 1)
  25. a.push_back(temp);
  26. else
  27. if (ttime > temp.in)
  28. push(temp);
  29. else{
  30. push(temp);
  31. ttime = a.front().in + a.front().out;
  32. out << a.front().num + 1 << " ";
  33. a.pop_front();
  34. }
  35. }
  36. while (a.size()){
  37. out << a.front().num + 1 << " ";
  38. a.pop_front();
  39. }
  40. return 0;
  41. }
  42.  
  43. int push(tt temp){
  44. tt temp1, temp2;
  45. temp1 = a.back();
  46. a.pop_back();
  47. temp2 = a.back();
  48. if (temp1.f == temp2.f && temp1.f != temp.f){
  49. while (temp2.f == temp1.f){
  50. a.pop_back();
  51. if (a.size())
  52. temp2 = a.back();
  53. else
  54. break;
  55. }
  56. }
  57. else
  58. a.push_back(temp1);
  59. a.push_back(temp);
  60. }
  61.  
  62. /*
  63. 6
  64. 1 1 100
  65. 2 2 2
  66. 2 3 2
  67. 2 4 2
  68. 2 5 2
  69. 1 6 1
  70.  
  71. 5
  72. 1 2 3
  73. 2 3 3
  74. 1 4 1
  75. 2 5 2
  76. 1 6 1
  77.  
  78. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement