题意

有\(n(1 \leq n \leq 2 * 10^5)\)个问题,第\(i\)个问题对应的主题是\(a_i\)。现在要组织\(t\)场考试

  • \(t\)场考试的主题互不相同
  • 为考试选取的问题的主题必须是该场考试的主题
  • 每场考试选取的问题个数必须是上一场考试选取的问题个数的两倍

题解

统计每个主题出现的次数,然后从小到大排序。因为每场考试的问题个数是上一场问题个数的2倍,所以\(t \leq 32\)。怎么确定第一场考试的题目数\(x\),因为\(t\)场考试的题目数是满足:\(x, 2x, 2^2x,2^3x,...,2^{t - 1}x\),所以用对应的考试题数,试除\(2^i\),取得最小值就是\(x\)。

代码

const int N = 200005;int n;
int a[N], b[N];int qpow(int x, int tt) {int c = 1;for (; tt; x = x * x, tt >>= 1) if (tt & 1) c = c * x;return c;
}map<int, int> use;
map<int, bool> vis;int main()
{cin >> n;Rep(i, 1, n) cin >> a[i], use[a[i]]++;int t = 0;Rep(i, 1, n) if (!vis[a[i]]) {vis[a[i]] = 1;b[++t] = use[a[i]];}sort(b + 1, b + t + 1);int cnt = 0, ans = b[t];for (int i = t - 1; i; --i) if (cnt <= 30) {cnt++;int res = INF32;for (int j = i, tot = 0; j <= t; ++j, ++tot) res = min(res, b[j] / qpow(2, tot));ans = max(ans, res * (qpow(2, t - i + 1) - 1));}cout << ans << endl;return 0;
}

转载于:https://www.cnblogs.com/zgglj-com/p/9973963.html

Thematic Contests -codeforce相关推荐

  1. LSNU寒假集训 题解

    目录 LSNU寒假第一场(基础算法+几何) A - Fifa and Fafa B - Anton and Lines C - Minimum path D - Thematic Contests E ...

  2. Codeforce 水题报告(2)

    又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...

  3. codeforce 1311 C. Perform the Combo 前缀和

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  4. 2017.5.28 codeforce h题思考记录

    并没有报codeforce  但有人想让我帮他看题,于是就做了 大概意思就是,给你200个空,让你在200个空中放字母,   再自己设计一个串,要求自己设计的这个串在这放着200个字母的串中作为子串出 ...

  5. AOAPC I: Beginning Algorithm Contests 题解

    AOAPC I: Beginning Algorithm Contests 题解 AOAPC I: Beginning Algorithm Contests (Rujia Liu) - Virtual ...

  6. 【CodeForce】559B Equivalent Strings 等效字符串

    [CodeForce]559B Equivalent Strings 等效字符串 B. Equivalent Strings time limit per test2 seconds memory l ...

  7. Codeforce题解:Shurikens

    题目链接:https://codeforces.com/contest/1413/problem/D 题干描述: Tenten runs a weapon shop for ninjas. Today ...

  8. 团体程序设计天梯赛 https://www.patest.cn/contests/gplt

    https://www.patest.cn/contests/gplt 代码: L2-21 //#include<iostream> //#include<cstdio> // ...

  9. CodeForce题解——Thanos Sort

    题目链接 CodeForce网站.http://codeforces.com/problemset/problem/1145/A. 我的小破站.http://47.110.135.197/proble ...

  10. Arrangement for Contests

    题目链接:Arrangement for Contests 比较显然的从左往右贪心,然后尽量不影响右边. 强行加了一个线段树. AC代码: #pragma GCC optimize("-Of ...

最新文章

  1. MYSQL——常用运算符和函数
  2. 磁盘修复工具TestDisk
  3. 并查集(Union-Find)算法介绍
  4. Map 3D 2013中的AcMapMap.GroupModified 和AcMapMap.LayerModified 事件的参数变化
  5. 现代信用卡管理(二)
  6. 一起学设计模式-策略模式
  7. 用 Ruby 买卖Bitcoin: 闪兑交易所 Exincore
  8. docker搜索镜像
  9. 常用正则表达式整理【总结】
  10. 12-图像梯度-Scharr算子和laplacian算子
  11. 免费!200块全志XR806开源鸿蒙开发板试用
  12. cubemx lan8720a ping不通_行刑的刀越用越钝,为啥刽子手却从不去磨?原因让外国人想不通!...
  13. 设计自己的基于Selenium 的自动化测试框架-Java版(3) - 给框架分分层
  14. BZOJ1127 POI2008KUP(悬线法)
  15. Android系统进阶
  16. 原来算法还能这样用图画出来?
  17. oracle数据库的监听配置
  18. android设置背景图片透明
  19. 你所不知道的Activity转场动画——ActivityOptions
  20. 数据链路层之以太网、MAC、MTU详解

热门文章

  1. 2.1HTML网页之table标签B
  2. 「易见股份」暴涨背后:炒区块链概念半年赚2亿
  3. C++之(public/protect/private)及fiend
  4. 帷幕的帷是什么意思_古时纺织什么样子?穿越时空看古代纺织发展
  5. 计算机专业教师的简历模板,教师简历模板
  6. 主流HTML5游戏开发引擎的分析和对比
  7. Unity 的Position和Rotation问题(坑)
  8. php页面添加背景图片,css怎么增加背景图片
  9. php公鸡五钱一只,PHP经典题:百钱百鸡问题(穷举算法)
  10. 启动报错:读取 jar时出错; error in opening zip file