codeforces Mafia
/*
* Mafia.cpp
*
* Created on: 2013-10-12
* Author: wangzhu
*/ /**
* 每个人都想玩若干场,求至少需要玩几场才可以满足大家的需求。
* 结果必然在某个人想玩的次数nmax(此人想玩的是最多的)与所有人想玩的次数和sum之间,
* 故二分,left = nmax,right = sum,
* 只需要需要玩的次数 * (总人数-1) >= 大家想玩的次数和即可
*
*/
#include<cstdio>
#include<iostream>
using namespace std;
#define LL long long
#define NMAX 100010
int arr[NMAX];
LL binary(int n, int nmax, LL sum) {
LL mid = -, left = nmax, right = sum;
while (left <= right) {
mid = left + (right - left) / ;
if (sum <= (mid * n)) {
right = mid - ;
} else {
left = mid + ;
}
}
return left;
}
int main() {
freopen("data.in", "r", stdin);
int n, nmax;
LL sum;
while(~scanf("%d",&n)) {
nmax = -;
sum = ;
for(int i = ;i < n;i++) {
scanf("%d",arr + i);
if(nmax < arr[i]) {
nmax = arr[i];
}
sum += arr[i];
}
printf("%I64d\n",binary(n - ,nmax,sum)); }
return ;
}
codeforces Mafia的更多相关文章
- Codeforces Round #202 (Div. 1) A. Mafia 贪心
A. Mafia Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/348/problem/A D ...
- CodeForces - 348A Mafia (巧妙二分)
传送门: http://codeforces.com/problemset/problem/348/A A. Mafia time limit per test 2 seconds memory li ...
- Codeforces Round #202 (Div. 1) A. Mafia 推公式 + 二分答案
http://codeforces.com/problemset/problem/348/A A. Mafia time limit per test 2 seconds memory limit p ...
- Codeforces Gym 100733H Designation in the Mafia flyod
Designation in the MafiaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/c ...
- Codeforces 348A Mafia
题目链接:http://codeforces.com/problemset/problem/348/A 题目大意:N个人中找出1个人主持,剩下N-1个人参与游戏,给出每个人想参与游戏的次数,问要满足每 ...
- Codeforces 349C - Mafia
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Codeforces 587D - Duff in Mafia(2-SAT+前后缀优化建图)
Codeforces 题面传送门 & 洛谷题面传送门 2-SAT hot tea. 首先一眼二分答案,我们二分答案 \(mid\),那么问题转化为,是否存在一个所有边权都 \(\le mid\ ...
- 【Codeforces 348A】Mafia
[链接] 我是链接,点我呀:) [题意] 每轮游戏都要有一个人当裁判,其余n-1个人当玩家 给出每个人想当玩家的次数ai 请你求出所需要最少的玩游戏的轮数 使得每个人都能满足他们当玩家的要求. [题解 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
随机推荐
- ArrayUtils用法
/* 1. ArrayUtils.isEmpty(strs) : 判断数组是否为空 , 不为空返回false,为空true */ ArrayUtils.isEmpty(new String[] ...
- spring beans的写入工具——spring-beans-writer
spring-beans-writer是我曾经为动态生成spring beans配置文件做的一个写入工具,托管地址: https://github.com/bluejoe2008/spring-bea ...
- C#学习笔记4:关键词大小写、复合格式化等
1.取消选择的单选按钮值 RadioButton1.Checked=RadioButton2.Checked = false;//RadioButton1.Text = RadioButto ...
- 使用repeater控件显示列表替代treeview
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- 微软阵营企稳的利好消息:.NET开源、Visual Studio免费
今天各个IT社区,头版头条说的是微软.NET开源了.宇宙中最好的IED–Visual Studio Community 2013将免费提供给用户的消息. <宇宙中最强大的开发环境免费了!> ...
- MarkDown中锚点的使用
在文档中创建锚点: <A NAME="ROP_ON_ARM">Davi L, Dmitrienko A, Sadeghi A R, et al. [Return-ori ...
- iOS UIView 快速修改 frame,
在iOS开发布局修改 frame 时需要繁琐的代码实现,今天偶尔看到一播客说到快速修改的 frame 的方法,自己动手写了一遍实现代码. 快速实现主要通过 添加类目的方式,对UIView 控件添加了一 ...
- ios--socket
一.打开服务器 a.在终端打开,到服务器文件路径输入命令 python chatserver.py b.当显示 Iphone Chat server started 表示成功 二.建立连接 a.设置对 ...
- python BeautifulSoup find 方法
这里我们重点讲一下find的几种用法,其他的类比: find(name=None, attrs={}, recursive=True, text=None, **kwargs) (ps:只讲几种用法, ...
- 关于window.location不跳转的问题
今天在码代码的时候遇到个问题:html里采用onclick事件来实现window.location = url的跳转,在内嵌元素上又加上了href="javascrit:;"的属性 ...