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 ...
随机推荐
- The socket is closed!
关闭mongodb /usr/local/app/mongidb//bin/mongod --shutdown --dbpath /usr/local/data/mongo/data/ 然 ...
- IOS - 零碎
---恢复内容开始--- 1.模拟器目录: ProjectNameApk.documents.library(cache.preference.cookies).temp 2.Edit-Refacto ...
- 3.1、Ansible命令简要说明及初步使用
1.Ansible命令 1.1 Ad-hoc说明 Ansible中有一个很重要的功能就是可以执行ad-hoc命令,它表示即时.临时的意思,即表示一次性的命令.与之相对的是ansible playboo ...
- Netty、NIO、多线程
一:Netty.NIO.多线程? 时隔很久终于又更新了!之前一直迟迟未动也是因为积累不够,后面比较难下手.过年期间@李林锋hw发布了一个Netty5.0架构剖析和源码解读,看完也是收获不少.前面的文章 ...
- 01.Python基础-3.集合容器
1 列表list 1.1 列表介绍 Python内置的一种数据类型是列表:list. 有序的集合,可随时添加和删除其中的元素. 每个元素都分配一个数字 --它的位置,或索引.0,1,2,3-- 可存放 ...
- Linux设备驱动--块设备(二)之相关结构体(转)
上回最后面介绍了相关数据结构,下面再详细介绍 块设备对象结构 block_device 内核用结构block_device实例代表一个块设备对象,如:整个硬盘或特定分区.如果该结构代表一个分区,则其成 ...
- V$PROCESS和V$SESSION,以及使用这两个视图能做什么
V$PROCESS和V$SESSION,以及使用这两个视图能做什么 http://blog.csdn.net/pan_tian/article/details/7731843 http://blog. ...
- NetOps Defined
https://www.logzilla.net/2017/06/20/the-network-operations-top-5.html
- [using_microsoft_infopath_2010]Chapter10 与SharePoint Designer工作流集成
本章概要: 1.创建工作流集成表单 2.允许工作流手动触发 3.创建自定义动作按钮 4.使用人物设计器 5.维护工作流人物表单
- 自己定义View实现水平滚动控件
前几天项目中须要使用到一个水平可滚动的选择条,类似下图效果(图片是从简书上一位作者那儿找来的,本篇也是在这位作者的文章的基础上改动的,站在大神的肩膀上,哈哈,因为原文没有提供demo,并且实现的效果跟 ...