codeforces 1077E Thematic Contests
题目:
传送门
题意:
给出一些题目的,其中有些题目是重复的,举办连续举办几场比赛,每次比赛的题目必须相同,但是一种题目只能举办一次比赛,而且后一场比赛的题目量必须是前一场的2倍,第一场比赛的题目量可以任意选择,之后的场比赛必须遵循上面的规则。
思路:
先对题目进行归类,即求出同一种题目的数量,然后排序,之后从初始一场到最多场开始找,在找的时候进行二分。
代码如下:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
map<ll,int>ma;
const int maxn=2*1e5+5;
ll a[maxn];
ll Min=0x3f3f3f3f,Max=-1;
int n,num=0;
ll sum=0;
ll Judge (ll x)
{ll tsum=0,j=x;int pos=0;while (1){pos=(lower_bound(a+1+pos,a+num+1,j)-(a+1));if(pos==num) break;pos++;tsum+=j;j<<=1;}return tsum;
}
int main()
{scanf("%d",&n);for (int i=0;i<n;i++){ll x;scanf("%lld",&x);if(ma[x]==0)ma[x]=++num;a[ma[x]]++;}sort(a+1,a+num+1);Min=a[1]; Max=a[num];ll l=Min,r=Max;for (ll i=1;i<=Max;i++){sum=max(sum,Judge(i));}printf("%lld\n",sum);return 0;
}
codeforces 1077E Thematic Contests相关推荐
- LSNU寒假集训 题解
目录 LSNU寒假第一场(基础算法+几何) A - Fifa and Fafa B - Anton and Lines C - Minimum path D - Thematic Contests E ...
- Codeforces Round #361 (Div. 2) B. Mike and Shortcuts bfs
B. Mike and Shortcuts 题目连接: http://www.codeforces.com/contest/689/problem/B Description Recently, Mi ...
- CodeForces 699C - Vacations
题目链接:http://codeforces.com/problemset/problem/699/C C. Vacations time limit per test1 second memory ...
- Dreamoon and Ranking Collection CodeForces - 1330A (贪心)
题意: 大意就是给一个序列,可能有重复数字,有x次机会为这个序列填上一个数字,问最终从里面获得的1~v连续子序列的v最大是多少. 题目: Dreamoon is a big fan of the Co ...
- Codeforces Round #307 (Div. 2) A. GukiZ and Contest 水题
A. GukiZ and Contest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/ ...
- 笔记-Codeforces比赛
笔记-Codeforces比赛 文章讲的是 Codeforces\texttt{Codeforces}Codeforces 的使用,所以需要先注册登入. 简介 Codeforces\texttt{Co ...
- Codeforces Round #807 (Div. 2)(A-D)
Dashboard - Codeforces Round #807 (Div. 2) - CodeforcesCodeforces. Programming competitions and cont ...
- codeforces csp复赛训练利器---初识
codeforces csp复赛训练利器---初识 1.解决codeforces访问慢的问题 网站https://www.codeforces.com打开极慢,换句话说,根本就打不开. 摘自https ...
- Codeforces Round #143 (Div. 2) (ABCD 思维场)
题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...
- Educational Codeforces Round 117
Problem - E - Codeforceshttps://codeforces.com/contest/1612/problem/E差个E,大概题意就是说(自己看去): 有很多人:给出喜欢的卡片 ...
最新文章
- RhinoMock入门(7)——Do,With和Record-playback
- http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.gridview.rowediting.aspx
- STC89C52单片机 独立键盘
- 【图像处理】——图像滤波(Python+opencv实现三种方法:均值滤波、中值滤波、高斯滤波等)
- vue-cli脚手架中webpack配置基础文件详解
- 在WPF中创建可换肤的用户界面
- 格式化json的方法
- MATPOWER 修改数据格式和应用
- 学习基础的html代码知识(入门篇)
- 计算机应用研究参考文献格式,参考文献编写规则-计算机应用研究.PDF
- php 手写签批 手机办公_好签原笔迹手写签批SDK
- 鸿蒙系统 微内核 sel4,微内核 seL4 Mapping
- Unhandled exception at 0x0133bc63 ....0xC0000005: Access violation reading location 0x00000004.
- [C++题目]:求和s=a+aa+aaa+…+aaa…a(n个a)
- docker镜像编译与docker-compose部署与编排
- 真北敏捷公众号里的群友
- 一飞库房管理系统 v1.0 bt
- 【20171015】【软工】结对项目
- fiddler安装证书失败
- 手感顺滑的平板键盘,更好用的Surface Pro伴侣,雷柏XK200S上手