/* 题目要求按注册者报告返回的时间顺序输出注册者的
* 编号,如果同一时间按出现,则先输出序号小的
* 大体思路:这个方法有点慢,先对注册者排序,然后每次输出
* 最先返回的,用find_min来找到最先返回的,复杂度有点高。
*/
#include<iostream>
#include<algorithm>
using namespace std;
struct Node{
int val;
int reg;
int sum;
}node[10000];
int n,k;
int find_min()
{
int min = node[0].sum;
int pos = 0;
for(int i=1;i<n;++i)
if(min>node[i].sum)
{
min = node[i].sum;
pos = i;
}
return pos;
}
int cmp(const Node& a,const Node& b)
{
return a.reg<b.reg;
}
int main()
{
char str[15];
int rgt,value,index,i,j;
n = 0;
while(1)
{
scanf("%s",str);
if(!strcmp(str,"#"))
break;
scanf("%d%d",&node[n].reg,&node[n].val);
node[n].sum = node[n].val;
++n;
}
sort(node,node+n,cmp);
scanf("%d",&k);
for(i=0;i<k;++i)
{
index = find_min();
node[index].sum +=node[index].val;
printf("%d\n",node[index].reg);
}
return 0;
}
#include<algorithm>
using namespace std;
struct Node{
int val;
int reg;
int sum;
}node[10000];
int n,k;
int find_min()
{
int min = node[0].sum;
int pos = 0;
for(int i=1;i<n;++i)
if(min>node[i].sum)
{
min = node[i].sum;
pos = i;
}
return pos;
}
int cmp(const Node& a,const Node& b)
{
return a.reg<b.reg;
}
int main()
{
char str[15];
int rgt,value,index,i,j;
n = 0;
while(1)
{
scanf("%s",str);
if(!strcmp(str,"#"))
break;
scanf("%d%d",&node[n].reg,&node[n].val);
node[n].sum = node[n].val;
++n;
}
sort(node,node+n,cmp);
scanf("%d",&k);
for(i=0;i<k;++i)
{
index = find_min();
node[index].sum +=node[index].val;
printf("%d\n",node[index].reg);
}
return 0;
}