GYM 101149 E.The Best among Equals(水~)
来源:互联网 发布:网络投票哪家好 编辑:程序博客网 时间:2024/05/22 06:31
Description
给出n支队伍的比赛得分上下限[l[i],r[i]],要求给每个队伍设定合适的分数使得最高分的队伍最多
Input
第一行一整数n表示队伍数,之后n行每行两个整数l[i]和r[i]分别表示第i支队伍的上下限(1<=n<=2e5,-1e9<=l[i]<=r[i]<=1e9)
Output
输出得到最高分队伍数量
Sample Input
3
1 3
2 4
4 5
Sample Output
3
Solution
最高分最少也是l的最大,要是得到最高分的队伍最多,那么最高分应该尽量小,令L=max(l[i])为最高分,答案即为r[i]>L的i的数量
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 222222int n,l[maxn],r[maxn];int main(){ while(~scanf("%d",&n)) { for(int i=0;i<n;i++)scanf("%d%d",&l[i],&r[i]); int Min=l[0]; for(int i=1;i<n;i++)Min=max(Min,l[i]); int ans=0; for(int i=0;i<n;i++) if(r[i]>=Min)ans++; printf("%d\n",ans); } return 0;}
0 0
- GYM 101149 E.The Best among Equals(水~)
- Gym 101149EThe Best among Equals 简单遍历
- GYM 100247 J. The Best Statement(水~)
- First among equals
- GYM 100182 E.Minesweeper(水~)
- GYM 100712 E.Epic Professor(水~)
- Effective C# 9:nderstand the Relationships Among ReferenceEquals(), static Equals(), instance Equals(), and operator==
- GYM 101149 F.The Weakest Sith(水~)
- GYM 101149 I.It's the Police(水~)
- Which machine learning algorithms can be considered as among the best?
- GYM 100488 E.Just Change a Word(水~)
- GYM 101102 E.Ya Rajaie and Books (水~)
- christian louboutin outlet Cartier Jewelry is available among forever the preferential designs for e
- GYM 100285 E. The Emperor’s plan(组合数学+dp)
- GYM 100285 B. The battle near the swamp(水~)
- Gym-101612E E
- Gym 101572E Emptying the Baltic(优先队列)
- gym 100935E (数学推导 水~)
- 粒子群算法通识
- A-RY的Steam库
- 【linux】ubuntu安装jdk
- java string == equals
- 转接IC GM7123:RGB转VGA 3通道高清视频编码电路
- GYM 101149 E.The Best among Equals(水~)
- 割点(模板)
- Linux中的Atime,Mtime,Ctime
- Docker windows安装tensorflow
- L2-002. 链表去重
- 行为型之备忘录模式
- java String 赋值
- ubuntu下使用脚本自动禁用笔记本触摸板和键盘
- Python字符串比较忽略大小写的方法