Advertisement
Dennnhhhickk

Untitled

Apr 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 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 push(tt temp){
  10. tt temp1, temp2;
  11. temp1 = a.back();
  12. a.pop_back();
  13. temp2 = a.back();
  14. //cout << temp1.fas << " " << temp2.fas << endl;
  15. if (temp1.fas == temp2.fas && temp.fas != temp1.fas)
  16. while (temp1.fas == temp2.fas){
  17. a.pop_back();
  18. if (a.size())
  19. temp2 = a.back();
  20. else
  21. break;
  22. //cout << temp1.fas << " " << temp2.fas << endl;
  23. }
  24. else
  25. a.push_back(temp1);
  26. a.push_back(temp);
  27. }
  28.  
  29. int main()
  30. {
  31. ifstream in("hats.in");
  32. ofstream out("hats.out");
  33. ll n, ttime;
  34. in >> n;
  35. tt temp;
  36. in >> temp.fas >> temp.in >> temp.out;
  37. out << "1 ";
  38. ttime = temp.in + temp.out;
  39. for (int i = 1; i < n; i++){
  40. in >> temp.fas >> temp.in >> temp.out;
  41. temp.num = i + 1;
  42. if (a.size() > 1)
  43. push(temp);
  44. else
  45. a.push_back(temp);
  46. if (ttime < temp.in)
  47. if (a.size()){
  48. ttime += a.front().out;
  49. out << a.front().num << " ";
  50. a.pop_front();
  51. }
  52. }
  53. while (a.size()){
  54. out << a.front().num << " ";
  55. a.pop_front();
  56. }
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement