【Codeforces】-629B-.Far Relative’s Problem(贪心.时间区间)

【杭电-oj】 -2111-Saving HDU(最对可以带走价值多少的宝藏) Problem Description 话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了。显然,作为多年拼搏的商人,XHD不会坐以待毙的。   一天,当他正在苦思冥想解困良策的时候,突然想到了自己的传家宝,那是公司成立的时候,父亲作为贺礼送来的一个锦囊,徐父当时交代,不到万不得已的时候,不要打开它。“现在不正是最需要的时候吗?”,一边想,XHD一边找到了这个精心保管的锦 阅读详情

点击打开链接

B. Far Relative’s Problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from ai to bi. Of course, Famil Door wants to have as many friends celebrating together with him as possible.

Far cars are as weird as Far Far Away citizens, so they can only carry two people of opposite gender, that is exactly one male and one female. However, Far is so far from here that no other transportation may be used to get to the party.

Famil Door should select some day of the year and invite some of his friends, such that they all are available at this moment and the number of male friends invited is equal to the number of female friends invited. Find the maximum number of friends that may present at the party.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 5000) — then number of Famil Door's friends.

Then follow n lines, that describe the friends. Each line starts with a capital letter 'F' for female friends and with a capital letter 'M' for male friends. Then follow two integers ai and bi (1 ≤ ai ≤ bi ≤ 366), providing that the i-th friend can come to the party from day ai to day biinclusive.

Output

Print the maximum number of people that may come to Famil Door's party.

Examples
input
4
M 151 307
F 343 352
F 117 145
M 24 128
output
2
input
6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200
output
4
Note

In the first sample, friends 3 and 4 can come on any day in range [117, 128].

In the second sample, friends with indices 3, 4, 5 and 6 can come on day 140.


这道题和饭店那道题差不多都是时间区间的问题。

题意:去XX人家,每个人都有一个可以去的开始时间和结束时间,车子只可以带男女数目相等的人,求最多去多少人。

题解:把从第一天到第366天每天可以去的人的数目算出来。

找到一个时间使得min(男生人数,女生人数)最大,最大值乘以2即可。


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int F[5050];
	int M[5050]; 
	int st,ed;
	while(~scanf("%d",&n))
	{
		memset(F,0,sizeof(F));
		memset(M,0,sizeof(M));
		for(int i=1;i<=n;i++)
		{
			getchar();
			char c;
			scanf("%c",&c);
			if(c=='F')
			{
				scanf("%d %d",&st,&ed);
				for(int i=st;i<=ed;i++)
					F[i]++;				//计算女生每天可以去的人数 
			}
			else
			{
				scanf("%d %d",&st,&ed);
				for(int i=st;i<=ed;i++)
					M[i]++;			//计算男生每天可以去的人数 
			}
		}
		int ans=0;
		for(int i=1;i<=366;i++)
		{
			if(F[i]<M[i])				//取男女人数的较小值,因为去的男女数必须相等 
				ans=max(ans,F[i]);		//但又是取ans的较大值 
			else
				ans=max(ans,M[i]);
		}
		printf("%d\n",ans*2);
	}
	return 0;
} 

Java电商秒杀系统性能优化(一)——电商秒杀系统框架回顾 电商秒杀系统框架回顾项目简介外部依赖框架回顾项目要点项目中存在的问题小结 课程是免费的,课程地址如下:SpringBoot搭建电商秒杀项目,课程真的很棒,作者的思路很清晰,建议各位读者可以跟着视频练习一下这个项目; 项目简介 通过SpringBoot快速搭建的前后端分离的电商基础秒杀项目。项目通过应用领域驱动型的分层模型设计方式去完成:用户otp注册、登陆、查看、商品列表、进入商品详情以及倒计时秒... 阅读详情

相关推荐

AI智能体评估基准AgentBench:从原理到实战的完整指南

在人工智能领域,智能体(AI Agent)的评估是衡量其实际应用能力的关键环节。评估基准通过设计标准化的测试任务,系统性地检验智能体的推理、规划和工具使用等核心能力。其技术价值在于为模型迭代和产品选型提供了客观、可复现的量化依据,能有效推动技术从演示走向工程落地。典型的应用场景包括模型能力评测、智能体框架对比以及具体应用(如自动化运维、智能客服)的性能验证。本文聚焦于清华团队推出的AgentBench,它作为一个多维度的综合评估套件,涵盖了从操作系统、数据库操作到网页浏览、数字卡牌游戏等八个贴近真实世界的任

weixin_27207591的博客 606

Codeforces--629B--Far Relative’s Problem(模拟)

Far Relative’s Problem Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Status Description Famil Door wants to celebra...

weixin_30670925的博客 167

ORACLE 12C RAC 启动报错,错误代码 ORA-27300,ORA-27301,ORA-27302

非一体机,12.2 无任何补丁,2套X86服务器,1节点集群异常(数据库正常,还有会话),2节点正常工作,负载不高,硬件、空间均未检查到异常,多路径存在掉线的情况,但通过Mulitpath -ll 看又是正常的,2根私有网络,其中一根不同,sysctl中配置的稀疏模式。5、再次加成crs alert ohas等集群日志,以及根据现象和错误再次到后台sr中查找可用信息,发现有一个类似问题,12.2 RAC 无任何补丁,报同样错误,解决方案为重启两套服务器。查询MOS文档以及后台文档,排除上面指出的问题。

weixin_42344665的博客 1466

Codeforces Round #343 (Div. 2) B. Far Relative’s Problem

B. Far Relative’s Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Famil Door wants to celebrate his

Code_KK的博客 732

STM32实现任意角度移相全桥PWM

STM32实现任意角度移相全桥PWM,最小分辨率0.5度,频率占空比课任意调节 本文重点在于如何产生任意角度的移相, 两个定时器工作于主从模式,从模式为Gate mode,用第一个定时器触发第二个来实现延时移相

Wind blog 3万+

基于STM32、HAL库的WF162A 11BA T&R气压传感器 驱动程序设计

/ 转换为7位地址。* @param temperature: 存储读取到的温度值(°C)* @param temperature: 存储读取到的温度值(°C)* @param pressure: 存储读取到的压力值(bar)* @param pressure: 存储读取到的压力值(bar)* @param range: 压力范围(bar)

corlin6688的博客 367

I - I CodeForces - 629B(暴力区间统计)

I - I CodeForces - 629B(暴力区间统计) Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of t...

做一只熊猫不好吗? 280

CARLA仿真:自定义地图与AI车辆行为编程

CARLA仿真:自定义地图与AI车辆行为编程 ,人工智能,计算机视觉,大模型,AI,本文围绕CARLA仿真平台,介绍了其基础功能与安装方法,详解地图系统,包括预设地图的加载切换及自定义地图的创建、导入与优化。还阐述了AI车辆的创建、属性设置、销毁,以及行为控制,如交通规则遵守、路径规划、复杂行为编程和行为树应用。同时涉及传感器与车辆感知、交通场景构建、自定义地图与AI行为结合应用、高级应用,以及常见问题解决方案和学习资源,为CARLA仿真应用提供全面指导。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 11万+

Codeforces 629B(贪心Far Relative’s Problem

Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from ai to bi. Of cour

王小二的博客 370

一文学会VOS2009对接网关指定走某个落地网关

介绍:  在我们日常使用VOS2009/3000的过程中,肯定会有很多落地网关与对接网关,并且某些时候还需要某些对接网关指定去走某个落地网关或者某些落地网关,从而实现比较精准的控制对接网关与落地网关的关系,下面就演示下在VOS2009/3000中如何配置某个对接网关指定走某个或者多个落地网关。 实现步骤:  VOS2009可以通过添加固定前缀的方式来指定对接网关走某个落地网关。 比如:  r1对接网关在被叫改写规则里面填写*:a*  r2对接网关在被叫改写规则里填写*:b* 1.登录VOS客户端 2.进入

非著名运维的博客 1966

畅游Diffusion数字人(0):专栏文章导航

畅游Diffusion数字人(0):专栏文章导航

沉迷单车的追风少年 1429

【CodeForces】[629B]Far Relative’s Problem

一直感觉这种题目不算贪心 但是却又看到好多把它分类到贪心 应该也是有关于区间贪心的写法 然而一直没想到也没找到相关写法 这个复杂度取决于区间大小 贪心策略取决于n的大小 应该也是可以有所抉择

BoilTask Talk Show 448

Python 安装 PyTorch(GPU)详细教程

本章教程,介绍如何安装PyTorch GPU版本的具体教程。

猿小白的博客 1661

CodeForces - 629B Far Relative’s Problem (贪心

B. Far Relative’s Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFamil Door wants to celebrate his birthday with his friends from Far Far A

Yishui_lovely 3543

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Codeforces 629B Far Relative’s Problem 区间贪心

区间贪心

Coding 342

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Codeforces 629B Far Relative’s Problem(简单区间贪心)

B. Far Relative’s Problem time limit per test  2 seconds memory limit per test  256 megabytes input  standard input output  standard output Famil Door wants to celebrate his

gzdrn的博客 526

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

CodeForces 629B Far Relative’s Problem(贪心)

文章在新的博客站点~欢迎~

AC是绝对不可能的 226

Codeforces 629B Far Relative’s Problem(简单区间贪心)

B. Far Relative’s Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Famil Door wants to celebrate his birth

Chunzhen的博客 809

Codeforces Round #343 (Div. 2) B. Far Relative’s Problem 暴力

B. Far Relative’s Problem 题目连接: http://www.codeforces.com/contest/629/problem/B Description Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of ...

weixin_30696427的博客 88

【杭电-oj】-4505-小Q系列故事——电梯里的爱情

Problem Description   细心的同事发现,小Q最近喜欢乘电梯上上下下,究其原因,也许只有小Q自己知道:在电梯里经常可以遇到他心中的女神HR。   电梯其实是个很暧昧的地方,只有在电梯里,小Q才有勇气如此近距离接近女神,虽然觉得有点不自在,但次数多了,女神也习惯了小Q的存在,甚至熟悉到仿佛不说上句话自己也都觉得不合适了。可是,他们的谈话也仅仅限于今天天气不错啊或是你吃了吗之类的

Bear1998的博客 787

【virtual judge】-已知拥有钱数求可以买的大米数量

对于幸存的灾民来说,最急待解决的显然是温饱问题,救灾部队一边在组织人员全力打通交通,一边在组织采购粮食。现在假设下拨了一定数量的救灾经费要去市场采购大米(散装)。如果市场有m种大米,各种大米的单价和重量已知,请问,为了满足更多灾民的需求,最多能采购多少重量的大米呢?    Input 输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和

Bear1998的博客 754

【Poj】-3069-Saruman's Army(贪心)

Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7611   Accepted: 3888 Description Saruman the White must lead his army along a straight pa

Bear1998的博客 662

【HDU】-1052-Tian Ji -- The Horse Racing(贪心,双端队列)

Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26393    Accepted Submission(s): 7785 Problem Description

Bear1998的博客 659

【HDU-oj]-1009-FatMouse' Trade(贪心)

FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 66462    Accepted Submission(s): 22584 Problem Description FatMouse

Bear1998的博客 617

【杭电-oj】-2037-今年暑假不AC(贪心,sort,结构体)

今年暑假不AC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 46778    Accepted Submission(s): 25088 Problem Description “今年暑假不AC?” “是的。

Bear1998的博客 582

【Poj】-1716-Integer Intervals(贪心)

Integer Intervals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14480   Accepted: 6151 Description An integer interval [a,b], a Write a program that: f

Bear1998的博客 552
上一篇: 【HDU】-4883-TIANKENG’s restaurant(贪心.时间区间)
下一篇: 【HDU]-1896-Stones(优先队列,好)
Bear1997
博客等级 码龄11年 55粉丝 369原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值