Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- struct tt{
- ll fas, in, out, num;
- };
- deque <tt> a;
- int push1(tt temp){
- tt temp1, temp2;
- temp1 = a.back();
- a.pop_back();
- temp2 = a.back();
- if (temp1.fas == temp2.fas && temp.fas != temp1.fas)
- while (temp1.fas == temp2.fas){
- a.pop_back();
- if (a.size())
- temp2 = a.back();
- else
- break;
- }
- else
- a.push_back(temp1);
- a.push_back(temp);
- //cout << "1" << endl;
- return 0;
- }
- int push(tt temp){
- if (a.size() > 1)
- push1(temp);
- else
- a.push_back(temp);
- return 0;
- }
- int main()
- {
- ifstream in("hats.in");
- ofstream out("hats.out");
- ll n, ttime = -100;
- in >> n;
- tt temp;
- bool bol;
- for (int i = 0; i < n; i++){
- in >> temp.fas >> temp.in >> temp.out;
- temp.num = i + 1;
- if (ttime >= temp.in){
- push(temp);
- }
- else{
- if (a.size()){
- out << a.front().num << " ";
- if (ttime > a.front().in)
- ttime += a.front().out;
- else
- ttime = a.front().in + a.front().out;
- a.pop_front();
- push(temp);
- }
- else{
- out << temp.num << " ";
- if (ttime > temp.in)
- ttime += temp.out;
- else
- ttime = temp.in + temp.out;
- }
- }
- }
- while (a.size()){
- out << a.front().num << " ";
- a.pop_front();
- }
- return 0;
- }
- /*
- 6
- 1 2 3
- 1 3 3
- 1 4 3
- 1 5 3
- 1 6 3
- 2 7 3
- 10
- 1 1 1
- 2 5 100
- 2 6 1
- 2 7 1
- 2 8 1
- 1 9 1
- 2 10 1
- 2 11 1
- 1 12 1
- 2 13 2
- 20
- 1 3 7
- 2 8 19
- 2 15 4
- 1 25 10
- 2 26 9
- 1 28 11
- 2 41 12
- 1 43 20
- 1 44 4
- 1 51 16
- 2 53 7
- 1 54 19
- 2 56 2
- 1 60 19
- 1 66 1
- 1 70 3
- 2 72 14
- 2 83 10
- 2 86 2
- 1 94 1
- 1 2 3 4 5 6 12 13 17 20
- 6
- 1 1 9
- 1 2 1
- 2 3 1
- 2 4 1
- 1 5 1
- 3 6 1
- 6
- 1 1 9
- 1 2 1
- 2 3 1
- 2 4 1
- 3 5 1
- 3 6 1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement