Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!s1.empty() && !s2.empty() && s1.begin()->ft < s2.begin()->ft){
- cur = *s1.begin();
- s1.erase(s1.begin());
- while (k && cur.ft >= 0){
- cur.ft -= x;
- k--;
- }
- if (cur.ft < 0){
- cur.ft *= -1;
- s2.ins(cur);
- }
- else
- s1.ins(cur);
- }
- else if (!s1.empty() && !s2.empty() && s1.begin()->ft >= s2.begin()->ft){
- cur = *s2.begin();
- s2.erase(s2.begin());
- while (k && cur.ft >= 0){
- cur.ft -= x;
- k--;
- }
- if (cur.ft < 0){
- cur.ft *= -1;
- s1.ins(cur);
- }
- else
- s2.ins(cur);
- }
- else if (!s1.empty()){
- cur = *s1.begin();
- s1.erase(s1.begin());
- while (k && cur.ft >= 0){
- cur.ft -= x;
- k--;
- }
- if (cur.ft < 0){
- cur.ft *= -1;
- s2.ins(cur);
- }
- else
- s1.ins(cur);
- }
- else{
- cur = *s2.begin();
- s2.erase(s2.begin());
- while (k && cur.ft >= 0){
- cur.ft -= x;
- k--;
- }
- if (cur.ft < 0){
- cur.ft *= -1;
- s1.ins(cur);
- }
- else
- s2.ins(cur);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement