| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不明白不用STL的是什么心态(附代码)#include <iostream>
#include <queue>
#include <vector>
#include <memory.h>
using namespace std;
typedef struct
{
int time;
int period;
int id;
} Reg;
struct cmp
{
bool operator()( Reg a, Reg b)
{
if(a.time == b.time)
return a.id>b.id;
else
return a.time>b.time;
}
};
int main()
{
char temp[10];
int id,period;
priority_queue<Reg,vector<Reg>,cmp> q;
while(cin>>temp)
if(temp[0]=='#')
break;
else
{
Reg r;
cin>>id>>period;
r.id = id;
r.period = period;
r.time = period;
q.push(r);
}
int k;
cin>>k;
while(k--)
{
Reg r = q.top();
cout<<r.id<<endl;
r.time += r.period;
q.pop();
q.push(r);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator