#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
struct hotel
{
int id;
int num;
int price;
}h[105];
int cmp(const void *a,const void *b){
hotelaa=*(hotel *)a;
hotelbb=*(hotel *)b;;
if(aa.price!=bb.price)
return aa.price-bb.price;
else
return aa.num-bb.num;
}
int main()
{
intt,c,s,i,j;
scanf("%d",&t);
while(t--){
int stu[1005],b[1005];
scanf("%d",&c);
for(i=0;i<c;i++)
scanf("%d %d%d",&h[i].id,&h[i].num,&h[i].price);
scanf("%d",&s);
for(i=0;i<s;i++)
scanf("%d",&stu[i]);
qsort(h,c,sizeof(h[0]),cmp);
for(i=0;i<s;i++){
for(j=0;j<c;j++){
if(h[j].num>=stu[i]) break;
}
if(j<c){
b[i]=h[j].id;
h[j].num-=stu[i];
}
else b[i]=0;
}
for(i=0;i<s;i++){
if(b[i])
printf("%d\n",b[i]);
else
printf("Sorry\n");
}
}
return0;
}
无题(hdu 1871)
最新推荐文章于 2022-01-12 06:35:58 发布