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 f, in, out, num;
- };
- deque <tt> a;
- int push(tt temp);
- ifstream in("hats.in");
- ofstream out("hats.out");
- int main()
- {
- ll n, m, ttime;
- tt temp;
- cin >> n;
- cin >> temp.f >> temp.in >> temp.out;
- cout << "1 ";
- ttime = temp.in + temp.out;
- for (int i = 1; i < n; i++){
- cout<<a.size()<<endl;
- in >> temp.f >> temp.in >> temp.out;
- temp.num = i;
- if (a.size() <= 1)
- a.push_back(temp);
- else
- if (ttime > temp.in)
- push(temp);
- else{
- push(temp);
- if (ttime < a.front().in)
- ttime = a.front().in + a.front().out;
- else
- ttime +=a.front().out;
- cout << a.front().num + 1 << " ";
- a.pop_front();
- }
- }
- while (a.size()){
- cout << a.front().num + 1 << " ";
- a.pop_front();
- }
- return 0;
- }
- int push(tt temp){
- tt temp1, temp2;
- temp1 = a.back();
- a.pop_back();
- temp2 = a.back();
- if (temp1.f == temp2.f && temp1.f != temp.f){
- while (temp2.f == temp1.f){
- a.pop_back();
- if (a.size())
- temp2 = a.back();
- else
- break;
- }
- }
- else
- a.push_back(temp1);
- a.push_back(temp);
- }
- /*
- 6
- 1 1 100
- 2 2 2
- 2 3 2
- 2 4 2
- 2 5 2
- 1 6 1
- 5
- 1 2 3
- 2 3 3
- 1 4 1
- 2 5 2
- 1 6 1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement