Codeforces div2 #499 B. Planning The Expedition 大水题
已经是水到一定程度了QAQ…
Code:
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 105;
int tp[maxn], idx[maxn], n,m, spare[maxn], cnt;
bool cmp(int i,int j) { return i > j;}
inline bool check(int val)
{
int fin = 0;
for(int i = 1;i <= n; ++i)
{
while(spare[i] >= val)
{
++fin, spare[i] -= val;
if(fin >= n) break;
}
}
if(fin >= n) return 1;
return 0;
}
int main()
{
//freopen("input.in","r",stdin);
scanf("%d%d",&n,&m);
for(int i = 1;i <= m; ++i)
{
int u; scanf("%d",&u);
if(!idx[u]) idx[u] = ++cnt;
++tp[idx[u]];
}
sort(tp + 1, tp + 1 + cnt, cmp);
int l = 1, r = 10000000, ans = 0;
while(l <= r)
{
int mid = (l + r) >> 1;
for(int i = 1;i <= cnt; ++i) spare[i] = tp[i];
if(check(mid)) l = mid + 1, ans = mid;
else r = mid - 1;
}
printf("%d",ans);
return 0;
}
Codeforces div2 #499 B. Planning The Expedition 大水题的更多相关文章
- Codeforces Round #499 (Div. 2) Problem-A-Stages(水题纠错)
CF链接 http://codeforces.com/contest/1011/problem/A Natasha is going to fly to Mars. She needs to bui ...
- Codeforces Round #499 (Div. 2) D. Rocket_交互题_二分
第一次作交互题,有点不习惯. 由于序列是循环的,我们可以将一半的机会用于判断当前是否是在说谎,另一半的机会用于二分的判断. 对于判断是否实在说谎,用1判断即可.因为不可能有比1还小的数. 本题虽然非常 ...
- CodeForces Round #499 Div2
A: Stages 题意: 给你n个字符, 现在需要从中选取m个字符,每个字符的花费为在字母表的第几位,并且如果选了某个字符, 那么下一个选择的字符必须要在字母表的2位之后, 假如选了e 那么 不能选 ...
- Codeforces Round #499(Div2) C. Fly (二分精度)
http://codeforces.com/contest/1011/problem/C 题目 这是一道大水题! 仅以此题解作为我这个蒟蒻掉分的见证 #include<iostream> ...
- Codeforces Round #499 (Div. 2)
Codeforces Round #499 (Div. 2) https://codeforces.com/contest/1011 A #include <bits/stdc++.h> ...
- Planning The Expedition(暴力枚举+map迭代器)
Description Natasha is planning an expedition to Mars for nn people. One of the important tasks is t ...
- Codeforces Round #499 (Div. 2)(1011)
Natasha is planning an expedition to Mars for nn people. One of the important tasks is to provide fo ...
- Codeforces Round #499 (Div. 1)部分题解(B,C,D)
Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...
- Codeforces Round #499 (Div. 1)
Codeforces Round #499 (Div. 1) https://codeforces.com/contest/1010 为啥我\(\rm Div.1\)能\(A4\)题还是\(\rm s ...
随机推荐
- day27-1 numpy模块
目录 numpy array 一维数组 二维数组(用的最多) np.array和list的区别 获取多维数组的行和列 多维数组的索引 高级功能 多维数组的元素替换 多维数组的合并 通过函数方法创建多维 ...
- 微电影《Junior·BQB》——剧本
电影名称:<Junior——BQB> 组长: 组员: 导演: 副导演: 分镜/演出: 编剧: 主演: 彬彬:比丘 阿伟:魔女(彬彬姐) 小怪:怪物团长 客串 旁白 友情演出: 恶俗之王 摄 ...
- jquery bind 传参数
方法一. ? 1 2 3 4 function GetCode(event) { alert(event.data.foo); } ? 1 2 3 4 $(document).ready(functi ...
- redis 参数配置总结
redis.conf 配置项说明如下 1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 daemonize no 2. 当Redis以守护进程方式运行时, ...
- 洛谷 1262 间谍网络 Tarjan 图论
洛谷 1262 图论 tarjan 并不感觉把这道题目放在图的遍历中很合适,虽然思路比较简单但是代码还是有点多的,, 将可收买的间谍的cost值设为它的价格,不可购买的设为inf,按照控制关系连图,T ...
- C#基础概念 代码样例
C# int与string一起操作时注意 1 int a1= 1; 2 string a2= "2"; 3 Console.WriteLine(a1+a2); 4 Console. ...
- gcc 源代码分析-前端篇2
2. 对ID及保留字的处理 在c语言中,系统预留了非常多keyword.也被称为保留字,比方表示数据类型的int,short,char,控制分支运行的if,then等. 不论什么keyword, ...
- 根据BDUSS获取用户ID信息
代码在 /data/svndir/business/workroot2/app/ecom/ubec/getuser
- HDU 1757
简单的矩阵构造题,参看我前几篇的谈到的矩阵的构造法. #include <iostream> #include <cstdio> #include <cstring> ...
- UVa11183 - Teen Girl Squad(最小树形图-裸)
Problem I Teen Girl Squad Input: Standard Input Output: Standard Output -- 3 spring rolls please. - ...