#include <iostream>
#include <string>
#include <queue>
using namespace std;
struct In
{
    int id;
    int ReturnTime; 
    int period;
    In(int i, int p):id(i), ReturnTime(p), period(p){}
 //重载写在在里面又怎么写? 
};
bool operator < (const In& x, const In& y)
{
    if(x.ReturnTime != y.ReturnTime)
        return x.ReturnTime > y.ReturnTime;
    return x.id > y.id;
}//为什么不是小于符号??? 

int main()
{
    string str;
    int k, id, period;
    priority_queue<In> que;
    for(int i = 0; cin >> str; ++i)
    {
        if(str == "#") break;
        else
            cin >> id >> period;
        In tmp(id, period);
        que.push(tmp);
    }
    cin >> k;
    while(k--)
    {
        In tmp = que.top();
        que.pop();
        cout << tmp.id << endl;
        tmp.ReturnTime += tmp.period;
        que.push(tmp);
    }
    return 0;
}
等我把重载搞懂了再回来写一遍

 

相关文章:

  • 2021-08-13
  • 2021-11-12
  • 2022-12-23
  • 2021-12-07
  • 2021-10-16
  • 2022-12-23
  • 2021-09-14
猜你喜欢
  • 2021-06-23
  • 2021-05-29
  • 2022-03-05
  • 2022-01-05
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案