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