啊。。我爱水题^ ^
要是题目再短点就好了。。。
题目大意是,给你ID 频率,给你询问次数K,问你前K个问题ID是多少。
直接优先队列,operator后面的<总是写成> = =。。。
出队后,当前频率加初始频率再入队即可。
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <queue>
#include <limits.h>
using namespace std;
typedef struct AUS{
int id;
int p,st;
}AUS;
bool operator<(AUS a,AUS b)
{
if( a.p == b.p )
return a.id > b.id;
return a.p > b.p;
}
priority_queue<AUS> q;
int main()
{
int num,id,p;
char str[10];
while( scanf("%s",str) && str[0] != '#' )
{
scanf("%d %d",&id,&p);
AUS tmp;
tmp.id = id;
tmp.st = p;
tmp.p = p;
q.push(tmp);
}
scanf("%d",&num);
while( num-- )
{
AUS tmp = q.top();
q.pop();
printf("%d/n",tmp.id);
tmp.p += tmp.st;
q.push(tmp);
}
return 0;
}