codeforces C. Booking System
题意:有n组客人,分别告诉每一组的个数和花费,然后给你餐厅内k个桌子,每个桌子的最大容纳人数,如何安排使得餐厅最大收益并且容纳人数尽可能大;
思路:贪心,对花费排序,然后对每一组客人找桌子就可以。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 2000
using namespace std;
struct node
{
int c,p,id;
bool operator <(const node &a)const
{
return (p>a.p)||(p==a.p&&c>a.c);
}
}q[maxn];
struct node1
{
int x,id;
bool operator <(const node1 &a)const
{
return x<a.x;
}
}p[maxn],pp[maxn];
bool vis[maxn];
int num[maxn]; int main()
{
int n,k;
scanf("%d",&n);
for(int i=; i<n; i++)
{
scanf("%d%d",&q[i].c,&q[i].p);
q[i].id=i+;
}
sort(q,q+n);
scanf("%d",&k);
for(int i=; i<=k; i++)
{
scanf("%d",&p[i].x);
p[i].id=i;
}
sort(p+,p+k+);
memset(vis,false,sizeof(vis));
int ans=,cnt=;
for(int i=; i<n; i++)
{
for(int j=; j<=k; j++)
{
if(p[j].x>=q[i].c&&!vis[p[j].id])
{
pp[cnt].x=q[i].id;
pp[cnt++].id=p[j].id;
ans+=q[i].p;
vis[p[j].id]=true;
break;
}
}
}
printf("%d %d\n",cnt,ans);
for(int i=; i<cnt; i++)
{
printf("%d %d\n",pp[i].x,pp[i].id);
}
return ;
}
codeforces C. Booking System的更多相关文章
- 会议室预订系统(meeting room booking system)
一.mrbs mrbs:(meeting room booking system) 二.效果 三.models from django.db import models # Create your ...
- (水题)Codeforces - 4C - Registration system
https://codeforces.com/problemset/problem/4/C 用来哈希的一道题目,用map也可以强行过,但是性能慢了6倍,说明是在字符串比较的时候花费了接近6倍的时间. ...
- 【codeforces 22C】 System Administrator
[题目链接]:http://codeforces.com/problemset/problem/22/C [题意] 给你n个点; 要求你构造一个含m条边的无向图; 使得任意两点之间都联通; 同时,要求 ...
- Codeforces 458A Golden System
经过计算两个字符串的大小对比 主要q^2=q+1 明明是斐波那契数 100000位肯定超LL 我在每一位仅仅取到两个以内 竟然ac了 #include<bits/stdc++.h> usi ...
- Codeforces 1321D Navigation System
题意 有个人要从\(s\)走到\(t\),经过的路径给定.导航系统每次会显示当前节点到\(t\)的最短路,有多条就显示其中之一.这个人如果按照导航走,那么啥都没变.如果没有按导航走导航就会重新导航.问 ...
- MRBS开源会议室预订系统安装
MRBS系统官方网址 https://mrbs.sourceforge.io/ 最近在找一份开源的会议室预订系统,找了很多种,ASP,PHP的,测试发现MRBS无疑是最好的.开源社区对其介绍如下:M ...
- mrbs - 初识
一.mrbs mrbs:(meeting room booking system)会议室预订系统 二.效果 三.models from django.db import models # Create ...
- Spring mvc解析
方案时间 ,写代码时间 ,解决技术难点时间 , 自测时间,解决bug时间 , 联调时间 ,数据库优化,代码走查1个接口:2个小时 把那个字段再复原回来,不然兼容性不强还有一个刷数据的接口 public ...
- python全栈开发之路
一.Python基础 python简介 python数据类型(数字\字符串\列表) python数据类型(元组\字典) python数据类型(集合) python占位符%s,%d,%r,%f prin ...
随机推荐
- shell从函数文件里调用函数
碰到一个shell中函数调用的小问题,记录一下. shell中函数有三种调用方式,一种是在文件前面定义函数,然后在以下直接调用:一种是通过加载shell,在shell中直接调用:第三种是将函数写入文件 ...
- Understanding JTS--reference
Part I-An introduction to transactions If you look at any introductory article or book on J2EE, you' ...
- Realm Configuration HOW-TO--官方
来源:https://secure.gettinglegaldone.com/docs/realm-howto.html Quick Start This document describes how ...
- 基于HTML5的SLG游戏开发(一):搭建开发环境(1)
开发环境: 1.操作系统:MacOS 10.8.5 2.本地web服务器:Apache 2.2.24 (Window环境推荐使用WampServer) 3.编码工具:WebStrom 7.0 4.调试 ...
- 实践过配置成功的VNC安装配置
VNC安装步骤说明那个 1.安装图形界面 #yum install tigervnc-server tigervnc 2.启动VNCServer #vncserver 对应的关闭图形界面的命令 ...
- ASP.NET 微信支付
一.在支付前期,我们需要获取用户的OpenId,此块内容只针对于JSAPI(微信中直接支付)才需要,如果生成二维码(NATIVE)扫描支付,请跳过此步骤 思路大致是:获取用户的code值 > 根 ...
- react初识
如下是在研究中记录的笔记: 1,作用:局部的更新dom结构;虚拟dom保证性能2,和mvc不同,mvc是对于技术上的分离(分类),而react是组件上的分离,每个视图模块分离,复用,以视图模块为单位3 ...
- java编程思想-异常
DynamicFields类的setField方法里面的getField方法抛出的异常NoSuchFieldException 为什么是throw new RuntimeException(e);
- 禁用windows 10自动更新
按Win键+R键调出运行,输入“gpedit.msc”点击“确定”,调出“本地组策略编辑器”.顺序依次展开计算机配置,管理模板 ,windows组件 ,windows更新 点击右边“配置自动更新”,选 ...
- Index Full Scan vs Index Fast Full Scan-1103
[Oracle] Index Full Scan vs Index Fast Full Scan作者:汪海 (Wanghai) 日期:14-Aug-2005 出处:http://spaces.msn. ...