Advertisement
Dennnhhhickk

Untitled

Apr 14th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 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. cin >> n;
  18. cin >> temp.f >> temp.in >> temp.out;
  19. cout << "1 ";
  20. ttime = temp.in + temp.out;
  21. for (int i = 1; i < n; i++){
  22. cout<<a.size()<<endl;
  23. in >> temp.f >> temp.in >> temp.out;
  24. temp.num = i;
  25. if (a.size() <= 1)
  26. a.push_back(temp);
  27. else
  28. if (ttime > temp.in)
  29. push(temp);
  30. else{
  31. push(temp);
  32. if (ttime < a.front().in)
  33. ttime = a.front().in + a.front().out;
  34. else
  35. ttime +=a.front().out;
  36. cout << a.front().num + 1 << " ";
  37. a.pop_front();
  38. }
  39. }
  40. while (a.size()){
  41. cout << a.front().num + 1 << " ";
  42. a.pop_front();
  43. }
  44. return 0;
  45. }
  46.  
  47. int push(tt temp){
  48. tt temp1, temp2;
  49. temp1 = a.back();
  50. a.pop_back();
  51. temp2 = a.back();
  52. if (temp1.f == temp2.f && temp1.f != temp.f){
  53. while (temp2.f == temp1.f){
  54. a.pop_back();
  55. if (a.size())
  56. temp2 = a.back();
  57. else
  58. break;
  59. }
  60. }
  61. else
  62. a.push_back(temp1);
  63. a.push_back(temp);
  64. }
  65.  
  66. /*
  67. 6
  68. 1 1 100
  69. 2 2 2
  70. 2 3 2
  71. 2 4 2
  72. 2 5 2
  73. 1 6 1
  74.  
  75. 5
  76. 1 2 3
  77. 2 3 3
  78. 1 4 1
  79. 2 5 2
  80. 1 6 1
  81.  
  82. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement