Booking System

Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!

A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.

There are n booking requests received by now. Each request is characterized by two numbers: ci and pi — the size of the group of visitors who will come via this request and the total sum of money they will spend in the restaurant, correspondingly.

We know that for each request, all ci people want to sit at the same table and are going to spend the whole evening in the restaurant, from the opening moment at 18:00 to the closing moment.

Unfortunately, there only are k tables in the restaurant. For each table, we know ri— the maximum number of people who can sit at it. A table can have only people from the same group sitting at it. If you cannot find a large enough table for the whole group, then all visitors leave and naturally, pay nothing.

Your task is: given the tables and the requests, decide which requests to accept and which requests to decline so that the money paid by the happy and full visitors was maximum.

Input

The first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of requests from visitors. Then n lines follow. Each line contains two integers: ci, pi(1 ≤ ci, pi ≤ 1000) — the size of the group of visitors who will come by the i-th request and the total sum of money they will pay when they visit the restaurant, correspondingly.

The next line contains integer k (1 ≤ k ≤ 1000) — the number of tables in the restaurant. The last line contains k space-separated integers: r1, r2, ..., rk (1 ≤ ri ≤ 1000) — the maximum number of people that can sit at each table.

Output

In the first line print two integers: m, s — the number of accepted requests and the total money you get from these requests, correspondingly.

Then print m lines — each line must contain two space-separated integers: the number of the accepted request and the number of the table to seat people who come via this request. The requests and the tables are consecutively numbered starting from 1 in the order in which they are given in the input.

If there are multiple optimal answers, print any of them.

Examples
Input
3
10 50
2 100
5 30
3
4 6 9
Output
2 130
2 1
3 2
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int m;
    int n;
    int s;
    int d;
}ar[10100];
bool cmp1(node a,node b)
{
    if(a.n!=b.n)  return(a.n>b.n);
    return (a.m<b.m);
}
struct node2
{
    int p;
    int q;
}br[10100];
bool cmp2(node2 a,node2 b)
{
    return(a.p<b.p);
}
int main()
{
    int i,j,k,w,sum1,sum2;
    sum1=sum2=0;
    scanf("%d",&w);
    for(i=1;i<=w;i++)
    {
        scanf("%d%d",&ar[i].m,&ar[i].n);
        ar[i].s=i;
        ar[i].d=0;
    }
    sort(ar+1,ar+i+w,cmp1);
    scanf("%d",&k);
    for(i=1;i<=k;i++)
    {
        scanf("%d",&br[i].p);
        br[i].q=i;
    }
    sort(br+1,br+1+k,cmp2);
    for(i=1;i<=w;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(ar[i].m<=br[j].p)
            {
                sum1++;
                sum2+=ar[i].n;
                ar[i].d=br[j].q;
                br[j].p=0;
                break;
            }
        }
    }
    printf("%d %d\n",sum1,sum2);
    for(i=1;i<=w;i++)
    {
        if(ar[i].d!=0)
        {
            printf("%d %d\n",ar[i].s,ar[i].d);
        }
    }
    return 0;
}






















目的使为了使获得最多的钱的数量,所以首先需要对顾客的金钱进行升序排序,顾客的人数可进行排序也可不进行排序,对结果没有太大的影响,必须对桌子进行升序的排序,这样使得最小的桌子优先满足最多钱数的顾客,这样为后面的顾客创造更多大的机会获得桌子,来取得利益的最大化,贪心的思想。
v2.3 更新时间:2011年6月13日 1.重新改写数据库访问底层,使优化后的页面加载速度比原来提升50% 2.系统添加有问必答栏目,将客户对酒店预订相关问题分页列出 3.对问题和回答添加顶帖功能 4.修正酒店详细信息浏览页的酒店问答标签中,查找不生效的Bug 5.修正问答详细页Title标签不生效的Bug 6.修正用户不注册生成酒店订单后,直接进入用户后台报错的Bug 7.总后台添加公司信息相关管理,内容包括:关于我们/与我们合作/法律声明/付款方式/联系我们/友情链接等 8.添加酒店点评汇总栏,对所有酒店点评/图片点评/好评/中评/差评等进行分页汇总,同时还有相应的点评搜索功能 9.修正首页没有滚动订单时,显示undefined的Bug      后台演示:http://demo.cms.bookinge.com/admin/    用户名:admin   密码:bookingecms   预订易酒店预订网站管理系统简称BookingE HotelCMS。是定位于中高端地方酒店预订网市场的CMS内容管理系统,能够以最低的成本,最少的人力投入,在最短的时间内架设一个功能齐全、性能优异的酒店预订平台。 6年的互联网产品开发经验,使得BookingE HotelCMS功能强大,系统稳定。3年的旅游网站落地运营,为BookingE HotelCMS注入了多项独特的盈利元素。独创的无级别分销体系,让您快速建立市场渠道,让运营不再是问题。 一、BookingE HotelCMS六大产品特色 1、强大智能的内容管理系统 立体式酒店介绍,让用户更全面了解酒店;标签式颜色印象,让用户快速了解酒店;实景图片展示(官方发布和网友实拍),让用户近距离感受酒店;动态地图,让用户轻松了解酒店所在位置和交通情况;互动式问答和点评,了解真实的酒店。 2、强大的会员管理系统 会员是一个旅游电子商务网站命脉,我们秉承这一设计理念,让用户通过多个途径,更简单的成为我们的会员。预订就得现金返还,更容易吸引新会员,留住老会员。简单的提现操作,让会员消费的同时,还能赚钱。 3、独创的无级别分销系统 通路决定销路,销路决定销量。通过独创的分销系统,可以快速建立自己的二级代理商,开启全民酒店预订新时代。只要有网络,就可以做酒店预订。 完全实现无纸化办公,只要有网络,就可以轻松完成订单;系统作业,准确,高效,便于管理。 4、人性化系统管理 每一个订单都有详尽的跟踪记录,便于客服人员记忆,管理人员监督。多种订单状态,让用户或分销商及时了解业务进展。每一个用户登录操作,系统均会生成日志,让管理一目了然。更多人性设计,请咨询我们的客户经理。 5、视觉颜色管理 独创的视觉颜色管理,根据色彩就可以判断用户性质、订单状态、酒店生效情况。。。将复杂的管理问题,简化成不同色彩,区分不同的情况,以直觉与目视的方法,实现轻松工作,高效管理。前台酒店印象,也采用此方法,大大提升用户使用体验。 6、多项互动式设计 网站的互动性决定了网站的人气。预订前咨询问答,预订后发表真实点评、分享酒店印象、上传实拍照片。入住点评和上传照片可以额外设置现金奖励,拉动人气。奖金数额可以根据自身情况,自行定义。 二、BookingE HotelCMS主要功能如下: 酒店管理系统 订单管理系统 会员管理系统 分销商管理系统(独有) 客房管理系统 房价管理系统(平日、周末、节假日、特殊时间) 酒店图片管理系统 酒店点评管理系统 酒店问答管理系统 酒店地图定位系统 星级自定义系统 区域自定义系统 商业区自定义系统 标志物自定义系统 用户后台管理系统 三、酒店预订项目分析 国民生活质量越来越高,自助旅游的人也越来越多。这些客人除了需要订酒店以外,还需要了解当地的旅游、交通、美食等信息。面对这样的市场,携程等巨头“一个呼叫中心服务全国”的模式受到严重挑战,他们解决不了用户的根本需求。 俗话说,强龙压不过地头蛇。做为本地化的我们,这是一个机会,我们可以弥补这一切。用户选择我们,不仅可以预订到合适的酒店,我们还可以担当向导的角色,给用户一站式服务体验。 同时也是一个挑战,我们需要用一个强大的网站平台,成熟的运营体系参与市场竞争。BookingE HotelCMS会成为您最坚实的后盾。 1、符合发展趋势  国内酒店越来越多,酒店市场营销面临空前压力。网络订房也逐渐成为旅友的首选;而大多数酒店本身不擅长网络营销。都是委托专业的酒店预订网站代为销售。 2、广阔的市场空间 一个城市少则几十家,多则几百家酒店,每家酒店的每间客房都相当于我们的一个产品。我们不需要一分钱投资,但可以无限销售。这只有酒店预订业才有的特殊待遇。 3、解决网络支付的顾虑问题 国内95%以上的酒店都支持客人前台现付。所以我们在销售的时候,不需向客人收取一分钱。从而大大减少销售的难度。这一点也是电子商务流域独有的待遇。 4、无需物流环节,减少风险 服务就是我们的产品。相比传统电子商务项目,物流环节成本高,风险大; 会给用户带来许多顾虑和烦恼。这也是酒店预订(电子商务)项目独有的优势。 5、无需库存、无需垫资,轻松无压力 传统电子商务项目均面临着大量资金的压力。为了保证效率,降低成本,必须得提前购买产品,存放在仓库。而酒店预订项目不需要一分钱投资,但可以无限销售;也不存在业绩要求带来的压力。 6、丰厚的利润 以普通经济型酒店120-150/间/晚来举例,我们每销售一间房,可以得到30-50元的佣金。毛利率达到20-30%。而我们需要付出的成本仅是接听一个电话,发送一个传真。相比大多传统行业,风险很低、投资回报率很高
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值