Far Relative’s Problem【 区间覆盖】
来源:互联网 发布:crm系统数据 编辑:程序博客网 时间:2024/05/25 08:13
S - Far Relative’s Problem
CodeForces - 629B
Famil Door wants to celebrate his birthday with his friends from Far Far Away. He hasn friends and each of them can come to the party in a specific range of days of the year fromai tobi. 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.
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 andbi (1 ≤ ai ≤ bi ≤ 366), providing that thei-th friend can come to the party from dayai to daybi inclusive.
Print the maximum number of people that may come to Famil Door's party.
4M 151 307F 343 352F 117 145M 24 128
2
6M 128 130F 128 131F 131 140F 131 141M 131 200M 140 200
4
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 day140.
代码
#include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>#include<queue>#include<stack>#include<vector>#define inf 0x3f3f3f#define mod 100000#define M 400using namespace std;struct data{int xx,yy; } ; data a[M];int main(){ int n;while(~scanf("%d",&n)){for(int i=0;i<M;i++)a[i].xx=a[i].yy=0; for(int i=0;i<n;i++){char k;int x,y;int kk;getchar(); scanf("%c%d%d",&k,&x,&y);if(k=='M') kk=1;else kk=0;for(int j=x;j<=y;j++){if(kk) a[j].yy++;else a[j].xx++;}}int sum=0;for(int i=0;i<M;i++){if(a[i].xx&&a[i].yy){int ll=min(a[i].xx,a[i].yy);if(ll*2>sum) sum=ll*2;}}printf("%d\n",sum); } return 0; }
- H - Far Relative’s Problem 【区间覆盖】
- Far Relative’s Problem【 区间覆盖】
- Far Relative’s Problem
- Far Relative’s Problem
- Far Relative’s Problem
- Codeforces 629B Far Relative’s Problem(简单区间贪心)
- Codeforces 629B Far Relative’s Problem(简单区间贪心)
- Codeforces Far Relative’s Problem(区间贪心)
- Codeforces 629B Far Relative’s Problem 区间贪心
- B. Far Relative’s Problem
- 【codeforces】Far Relative’s Problem
- 【codeforces】 Far Relative’s Problem
- CodeForces 629B Far Relative’s Problem
- B. Far Relative’s Problem【思维】
- Far Relative’s Problem(贪心算法)
- CodeForces Far Relative’s Problem (贪心)
- Far Relative’s Problem(贪心模拟)
- codrecorces B. Far Relative’s Problem
- pop3接收邮箱/pop3_ssl接收邮箱
- HBaseJava10000
- BZOJ 1026 [SCOI2009] windy数
- NPM 使用介绍
- 全概公式和贝叶斯公式的理解
- Far Relative’s Problem【 区间覆盖】
- java操作csv文件(读、写)
- CUDA/ GPU: CUDA核函数的运行参数
- 蓝桥杯 合并石子
- BZOJ 4580: [Usaco2016 Open]248
- 算法练习——List_Throw
- 深入探究Blocks----------截获不同种类的自动变量
- 算法联系——复数运算
- 工厂模式和抽象工厂模式