已经是水到一定程度了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 大水题的更多相关文章

  1. 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 ...

  2. Codeforces Round #499 (Div. 2) D. Rocket_交互题_二分

    第一次作交互题,有点不习惯. 由于序列是循环的,我们可以将一半的机会用于判断当前是否是在说谎,另一半的机会用于二分的判断. 对于判断是否实在说谎,用1判断即可.因为不可能有比1还小的数. 本题虽然非常 ...

  3. CodeForces Round #499 Div2

    A: Stages 题意: 给你n个字符, 现在需要从中选取m个字符,每个字符的花费为在字母表的第几位,并且如果选了某个字符, 那么下一个选择的字符必须要在字母表的2位之后, 假如选了e 那么 不能选 ...

  4. Codeforces Round #499(Div2) C. Fly (二分精度)

    http://codeforces.com/contest/1011/problem/C 题目 这是一道大水题! 仅以此题解作为我这个蒟蒻掉分的见证 #include<iostream> ...

  5. Codeforces Round #499 (Div. 2)

    Codeforces Round #499 (Div. 2) https://codeforces.com/contest/1011 A #include <bits/stdc++.h> ...

  6. Planning The Expedition(暴力枚举+map迭代器)

    Description Natasha is planning an expedition to Mars for nn people. One of the important tasks is t ...

  7. 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 ...

  8. Codeforces Round #499 (Div. 1)部分题解(B,C,D)

    Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...

  9. Codeforces Round #499 (Div. 1)

    Codeforces Round #499 (Div. 1) https://codeforces.com/contest/1010 为啥我\(\rm Div.1\)能\(A4\)题还是\(\rm s ...

随机推荐

  1. 路飞学城Python-Day181

    Evernote Export Nginx默认网站 当Nginx配置文件中有且仅有一个Server的时候,该Server就被Nginx认为是默认网站,所有发给Nginx服务器80端口的数据都会默认给s ...

  2. js操作url参数

    function getQueStr(url, ref) //获取参数值 { var str = url.substr(url.indexOf('?') + 1); if (str.indexOf(' ...

  3. Untiy中的数据平滑处理

    本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/50680237 作者:car ...

  4. codeforces Towers 题解

    Little Vasya has received a young builder's kit. The kit consists of several wooden bars, the length ...

  5. Ubuntu14.04编译WebRTC For Android代码 2014-07-24

    整整快一年没有写博客了.近期基于Google开源的WebRTC项目做了一款音视频聊天的即时通信项目,期间在下载WebRTC代码时就碰到了一些问题.在此以作记录,也希望可以帮助到正在下载编译WebRTC ...

  6. php实现简单的学生管理系统

    php实现学生管理系统 一.效果 二.代码框架 functions文件夹里面是封装的mysqli的数据库操作函数和一个跳转的函数 student文件夹里面就是学生管理系统的主界面 applicatio ...

  7. [jzoj 6092] [GDOI2019模拟2019.3.30] 附耳而至 解题报告 (平面图转对偶图+最小割)

    题目链接: https://jzoj.net/senior/#main/show/6092 题目: 知识点--平面图转对偶图 在求最小割的时候,我们可以把平面图转为对偶图,用最短路来求最小割,这样会比 ...

  8. 服务器未能识别http头soapaction的值

    公司真是坑的一比 ,连接PDA报出这个错误 网上找的解决方案: 加什么wsdl http://www.cnblogs.com/dengxinglin/archive/2012/05/02/247868 ...

  9. POJ 2923 DP

    题意: 两辆车去运一堆货物,货物数量小于等于10,问最少需要几趟能把货物全部运到目的地. 思路: 思路很简单,就是状态压缩成二进制.判断一下每个状态能不能运输.再进行一下DP. 设s[]数组里记录所有 ...

  10. 在centOS 6.5下手动安装nginx1.9.x版本

    第一步:首先安装Nginx的依赖环境    1.安装pcre-devel   yum -y install pcre-devel  #支持正则的pcre模块 比如安装 不然手动安装会报错    2.安 ...