E. Thematic Contests 二分,离散化
题目意思是给你n个问题即数字,n的大小代表问题所在的话题,题目要求举办多场比赛,每场比赛的只能一种问题,且后一场比赛的问题必须是前一场的两倍,求举办比赛可能最多的问题总数
解题思路:将出现每种数字对应的话题从一开始标记,用a记录对饮数字出现的次数,排序后,枚举第一场可能的问题次数,之后二分查找后面是否存在问题的二倍数量存在就加上,直到不足二倍。
#include<bits/stdc++.h>
using namespace std;
map<int, int> mp;
const int maxn=2e5+;
int a[maxn];
int main()
{
int n;
scanf("%d", &n);
int cnt=;
for(int i=; i<=n; i++)
{
int t;
scanf("%d", &t);
if(mp[t]==)
mp[t]=++cnt;
a[mp[t]]++;
}
sort(a+, a++cnt);
int maxx=-;
// for(int i=1; i<=cnt; i++)
// printf("%d ", a[i]);
// printf("\n");
for(int i=; i<=a[cnt]; i++)
{
int ans=;
int la=;
for(int j=i; j<=a[cnt];j=j*)
{
int pos=lower_bound(a+la,a++cnt,j)-a;
if(pos==cnt+)
break;
else
{
ans+=j;
}
la=pos+;
}
maxx=max(maxx,ans);
}
printf("%d", maxx);
}
E. Thematic Contests 二分,离散化的更多相关文章
- Codeforces Round #521 (Div. 3) E. Thematic Contests (离散化,二分)
题意:有\(n\)个话题,每次都必须选取不同的话题,且话题数必须是上次的两倍,第一次的话题数可以任意,问最多能选取多少话题数. 题解:我们首先用桶来记录不同话题的数量,因为只要求话题的数量,与话题是多 ...
- Codeforces 1077E Thematic Contests(二分)
题目链接:Thematic Contests 题意:给出n道有类型的题目,每天组织一场专题比赛,该天题目数量必须是前一天的2倍,第一天的题目数量可以任意选择,求能消耗的最多题目数量. 题解:先整理成不 ...
- Codeforces Round #521 (Div. 3) E. Thematic Contests(思维)
Codeforces Round #521 (Div. 3) E. Thematic Contests 题目传送门 题意: 现在有n个题目,每种题目有自己的类型要举办一次考试,考试的原则是每天只有一 ...
- 计蒜客 38229.Distance on the tree-1.树链剖分(边权)+可持久化线段树(区间小于等于k的数的个数)+离散化+离线处理 or 2.树上第k大(主席树)+二分+离散化+在线查询 (The Preliminary Contest for ICPC China Nanchang National Invitational 南昌邀请赛网络赛)
Distance on the tree DSM(Data Structure Master) once learned about tree when he was preparing for NO ...
- CodeForces Round #521 (Div.3) E. Thematic Contests
http://codeforces.com/contest/1077/problem/E output standard output Polycarp has prepared nn competi ...
- 1077E Thematic Contests 【二分答案】
题目:戳这里 题意:n个数代表n个problem,每个数的值代表这个问题的topic,让我们挑出一些problems,满足挑出problems的topic是首项为a1公比为2的等比数列(每种topic ...
- [luogu4479][BJWC2018]第k大斜率【二维偏序+二分+离散化+树状数组】
传送门 https://www.luogu.org/problemnew/show/P4479 题目描述 在平面直角坐标系上,有 n 个不同的点.任意两个不同的点确定了一条直线.请求出所有斜率存在的直 ...
- 51nod 1686 二分+离散化
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1686 1686 第K大区间 基准时间限制:1 秒 空间限制:131072 ...
- $Poj3179\ Corral\ the\ Cows$ 二分+离散化+二维前缀和
Poj $Description$ 在一个二维平面上,有$N$颗草,每颗草的大小是$1*1$,左下角坐标为$x_i,y_i$.要求一个正方形,正方形的边平行于$x$或$y$轴,正方形里面包含至少$C$ ...
随机推荐
- C# 之 GUID格式化
Guid的带参数的ToString()方法来实现格式化,如下: //// 摘要: // 根据所提供的格式说明符,返回此 System.Guid 实例值的字符串表示形式. //// 参数: // ...
- zabbix实操随笔
vmware 9.0安装,vmware tools安装 fedora 15.0安装1G内存以上fedora上基本操作指令1.vmtools 共享文件在linux上安装有问题,出现找不到**.so.1之 ...
- python全栈开发day82-modelForm
1.jsonp内容 from django.shortcuts import render # Create your views here. def upload(request): if requ ...
- @+id/和android:id有什么区别?
Any View object may have an integer ID associated with it, to uniquely identify the View within the ...
- python 进阶读书笔记2 -- python魔法函数
#!/usr/bin/env python# -*- coding: utf-8 -*- class student: def __init__(self, name_list): self.stud ...
- Linux read line
cat ./port_list|while read linedo done
- day33 网络编程之线程,并发以及selectors模块io多路复用
io多路复用 selectors模块 概要: 并发编程需要掌握的知识点: 开启进程/线程 生产者消费者模型!!! GIL全局解释器锁(进程与线程的区别和应用场景) 进程池线程池 IO模型(理论) 1 ...
- Python 枚举 enum
Python 枚举 enum enum 标准模块在 3.4 版本才可以使用,3.3 以下版本需要独立安装:https://pypi.python.org/pypi/enum34#downloads,官 ...
- easyui+themeleaf 分页查询实现
<!DOCTYPE html> <html xmlns:th="http://www.w3.org/1999/xhtml"> <head> &l ...
- 斐波那契数列-java编程:三种方法实现斐波那契数列
题目要求:编写程序在控制台输出斐波那契数列前20项,每输出5个数换行 斐波那契数列指的是这样一个数列:1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, … 这个数列 ...