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

Codeforces Round #343 (Div. 2) 解题报告 Codeforces Round #343 (Div. 2) 阅读详情
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 bi inclusive.

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.

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
bool cmp(int x,int y)
{
return x > y;
}
int arr[400], brr[500], crr[500];
int main()
{
    int a, b;
    char c;
    int n;
    while(~scanf("%d",&n)){
        getchar();
        memset(arr,0,sizeof(arr));
        memset(brr,0,sizeof(brr));
        memset(crr,0,sizeof(crr));
        while(n--){
            scanf("%c %d%d",&c,&a,&b);
            getchar();
            if(c=='F'){
                for(int i = a;i <= b; i++)
                    arr[i]++;
            }
            if(c=='M'){
                for(int i = a;i <= b; i++)
                    brr[i]++;
            }
        }
        for(int i = 0;i < 500; i++){
            crr[i] = min (arr[i],brr[i]);
        }
        sort(crr,crr+500,cmp);
        printf("%d\n",crr[0]*2);
    }
return 0;
}
电力系统直流潮流计算研究【IEEE9节点】(Matlab代码实现) 内容概要:本文围绕《电力系统直流潮流计算研究【IEEE9节点】(Matlab代码实现)》展开,系统介绍了基于IEEE9标准测试系统的直流潮流计算方法及其Matlab编程实现过程。资源内容聚焦于电力系统稳态分析中的核心问题,详细阐述了直流潮流的数学模型构建、节点导纳矩阵形成、功率注入处理及线性方程组求解等关键技术环节,并提供完整的可运行Matlab代码,便于读者理解与复现。该研究不仅适用于电力系统规划、运行与控制的教学实践,还可作为复杂电网分析的前期基础工具,服务于故障分析、网络重构与优化调度等高级应用场景。该资源隶属于涵盖智能优化算法、机器学习、电力系统管理等多个方向的综合性科研资料体系,具有较高的工程参考价值和教学实用性。; 适合人群:具备电力系统分析基础知识及一定Matlab编程能力的高校电气工程及相关专业的本科生、研究生、科研人员,以及从事电力系统仿真、电网调度与自动化领域的工程技术人员。; 使用场景及目标:①深入理解直流潮流计算的基本原理及其在电力系统分析中的作用;②利用IEEE9节点系统开展教学实验、课程设计或科研验证,掌握潮流计算的数值实现方法;③作为电力系统高级应用(如最优潮流、可靠性评估、分布式电源接入分析)的前置模块进行扩展研究。; 阅读建议:建议读者结合经典电力系统分析教材同步学习,重点理解潮流计算的数学建模思路与Matlab代码的实现逻辑,通过实际运行、调试程序加深对算法流程的理解,并尝试将该方法迁移至其他IEEE标准测试系统(如IEEE14、IEEE30等)进行对比分析,以提升综合应用能力。 立即下载

相关推荐

openlayers6【十九】vue HeatmapLayer热力图层实现热力图效果详解

文章目录1. 写在前面2. Heatmap 类实现热力图2.1 Heatmap 参数2.2 实现热力图3. 完整代码4. 添加删除map图层的方法5. 热力图自身的get,set方法 1. 写在前面 我们主要看热力图的效果,区域绘制效怎么设置详细内容可以访问 openlayers6【十七】vue VectorLayer矢量图层画地图省市区,多省市区(粤港澳大湾区)效果详解 在 openlayers 中,图层是使用 layer 对象表示的,主要有 WebGLPoints Layer、热度图(HeatMap L

@必意玲 1万+

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

分布式光纤传感(DFOS)DTS/DAS/DSS 三合一:10公里管线监测实战与数据解读

本文详细介绍了分布式光纤传感(DFOS)技术在10公里管线监测中的实战应用,通过DTS(温度)、DAS(振动)、DSS(应变)三合一系统,实现对管线健康状态的立体感知。文章涵盖工程部署、数据采集、多物理量数据融合及噪声抑制等关键技术,展示了如何通过一根光纤完成复杂监测任务,显著提升管线安全性和维护效率。

weixin_29168153的博客 318

[2020-2-28]BNUZ套题比赛div3解题报告

[2020-2-28]BNUZ套题比赛div3解题报告 2020/3/8 上周因为偷懒,没有写上周训练赛的解题报告,不过该写还是要写的。然后非常荣幸能拿到本次训练赛的第一名*(排名如下图)* 第一题 Far Relative’s Birthday Cake Door’s family is going celebrate Famil Doors’s birthday party. They l...

BNUZ_Clearlove的博客 562

SenseVoice 实测,阿里开源语音大模型,识别效果和效率优于 Whisper,居然还能检测掌声、笑声!5分钟带你部署体验

阿里开源语音大模型:语音识别效果和性能强于 Whisper,还能检测掌声、笑声、咳嗽等

u010522887的专栏 4万+

医学影像弹性形变处理

这段代码的主要流程是:读取 DICOM 医学影像,尝试使用 MONAI 进行弹性形变(根据版本适配),如果失败则使用 OpenCV 实现,最后可视化并保存处理结果。这样可以在不同环境下灵活处理医学影像的弹性形变需求。后面会写一篇解释弹性变形方法的短文。

wh_xia_jun的专栏 785

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

ZYNQ工业级串口方案:AXI UART 16550扩展RS-485实战(自动方向控制+Linux驱动)

可以轻松扩展出多路工业级串口。但常规方案需要手动控制收发方向(DE/RE引脚),存在实时性差、CPU占用高等痛点。本文从硬件逻辑设计到Linux驱动开发,完整实现了ZYNQ平台的RS-485工业通信方案。,解决了传统方案实时性差的痛点。所有代码均经过实际项目验证,可直接用于生产环境。:尝试将此设计扩展为多协议兼容接口(支持RS-422/RS-232切换)!等特性,依然是现场总线通信的首选。,通过硬件逻辑+Linux驱动协同设计,实现零延迟切换。在工业自动化、能源电力等场景中,RS-485凭借。

QQ_778132974的博客 836

Far Relative’s Problem(贪心算法)

Far Relative’s Problem 求参加宴会的情侣个数

傲娇的晓明 583

【AI大模型应用开发实战】大型语言模型评估指南白皮书(LLM Eval)

近年来,大型语言模型(LLM)在自然语言处理领域取得了重大进展,例如 GPT-3 和 Chat-GPT。这些模型经过大型数据集的训练,在文本相关任务中表现出卓越的能力,甚至超越了人类。本文将简要介绍如何验证 LLMs 性能的评估指标。自然语言处理(NLP)是人工智能的一个领域,涉及计算机和人类语言之间的交互。NLP 的基本任务之一是语言建模 (LM),它涉及构建统计模型来分析和生成自然语言。LM 已成为推进机器语言智能的关键方法,使机器能够执行机器翻译、情感分析和对话系统等任务。

AI天才研究院 1023

【WSN定位】基于AOA算法实现目标无源定位附matlab代码

1 简介 2 部分代码 clear all; close all; clc;​stations = [0 0 0;20 0 0]; %基站位置​X = -100:100; %生成目标位置Y = X.*sin(X);Z = X+Y;N = length(X);Locations = zeros(N,3);angs = zeros(N,4);for i = 1:N angs(i,:) = Angs(stations*1e3,[X(i),Y(i),Z(i)]*1e3);end​for

qq_59747472的博客 2316

Far Relative’s Problem(贪心)

H - Far Relative’s Problem Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit   Status Description Famil Door wants to celebrate his birthday with his friends f

Oenheng的博客 357

【SAP HANA 24】HANA与Oracle SQL语法对照表

HANA SQL参考及Oracle 语法对照

探索 Java 编程的技巧、最佳实践和解决方案。本博客提供针对 Java 开发者的实用指南,涵盖从基础到高级话题,旨在提升编程效率和技能。 1432

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

区间贪心

Coding 342

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

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

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

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

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

AC是绝对不可能的 226

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

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

【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 Doo

Bear1998的博客 483

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】[629B]Far Relative’s Problem

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

BoilTask Talk Show 448

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

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

【codeforces】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 celebrate his birthday with his frien

~★sunshine☆的博客专栏 313

Far Relative’s Problem (贪心 计算来的最多客人)

Description Famil Door wants to celebrate his birthday with his friends from Far Far Away. He hasnfriends and each of them can come to the party in a specific range of days of the year fromai...

weixin_33828101的博客 156

Codeforces Round #343 (Div. 2) A B C D

链接:戳这里 A. Far Relative’s Birthday Cake time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Door's family is going celebrate Famil Doors's

Cross 789
上一篇: HDUoj 1084 What Is Your Grade?( 贪心 水
下一篇: POJ 2431 Expedition (优先队列
Yishui_Blog
博客等级 码龄10年 96粉丝 524原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值