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 ...
随机推荐
- RHEL 7 & CentOS 7禁用IPV6(转载)
RHEL 7 & CentOS 7下禁用IPV6的方法和之前的版本不太一样了,本文整理了一下处理方法: 首先,我们必须给出最根本的解决方法:修改grub,在引导时就不加载IPV6模块 这样修改 ...
- WEBGL学习【十一】光照模型
<!DOCTYPE HTML> <html lang="en"> <head> <title>Listing 7-3 and 7-4 ...
- LAMP环境下,通过网页url获取gb2312编码中文命名的下载资源方法
最近有个功能, 要求获取中文命名的.zip压缩文件,我准备直接采用网页url填写压缩文件地址的方式获取下载资源, 但问题是 我们的linux系统和php编程环境都是采用的zh_GB2312编码, 而浏 ...
- uni-app 路由navigate
uni-app 是一个使用 Vue.js 开发跨平台应用的前端框架,开发者编写一套代码,可编译到iOS.Android.H5.小程序等多个平台. 公司最近在写APP应用到了uni-app 我在写的时 ...
- K - The Unique MST
K - The Unique MST #include<iostream> #include<cstdio> #include<cstring> #include& ...
- stylesheet_link_tag,javascript_include_tag无效?
stylesheet_link_tag,javascript_include_tag无效? http://stackoverflow.com/questions/28241981/rails-4-ex ...
- AS常见的错误
导入的项目使用的gradle版本和本地的要一致,不然会提示类似"Minimum supported Gradle version is 3.3. Current version is 2.1 ...
- 数据库SQL Server2012笔记(三)——表的复杂查询
1.数据分组--max/min/avg/sum/count select avg(字段名),sum(字段名) from 表名 select count(*) from 表名 select ...
- audio_coding模块分析和audio_conference_mixer模块分析
audio_coding 1. 主要接口 AudioCodingModuleImpl::RegisterReceiveCodec 初始化Codec AudioCodingModul ...
- UI_KVC赋值
使用KVC对person的属性进行赋值 [aperson setValue:@"yadong" forKey:@"name"]; [aperson setVal ...