【链接】 我是链接,点我呀:)

【题意】

每轮游戏都要有一个人当裁判,其余n-1个人当玩家
给出每个人想当玩家的次数ai
请你求出所需要最少的玩游戏的轮数
使得每个人都能满足他们当玩家的要求.

【题解】

```cpp
/*
* 如果有x轮的话
* 理论上每个人都能玩x次
* 但是必须有x人当supervisor
* x次的话,每个人能当supervisor的次数为x-a[i]
* n*x-∑a[i]就是所有人除去必须的能打supervisor的次数
* 如果n*x-∑a[i] >= x 那么就ok
* (n-1)*x-∑a[i]>=0就好
*x>=∑a[i] / (n-1)
*要注意x需要大于等于max{a[i]}
*/
```

【代码】

import java.io.*;
import java.util.*; public class Main { static InputReader in;
static PrintWriter out; public static void main(String[] args) throws IOException{
//InputStream ins = new FileInputStream("E:\\rush.txt");
InputStream ins = System.in;
in = new InputReader(ins);
out = new PrintWriter(System.out);
//code start from here
new Task().solve(in, out);
out.close();
} static int N = 100000;
static class Task{
/*
* 如果有x轮的话
* 理论上每个人都能玩x次
* 但是必须有x人当supervisor
* x次的话,每个人能当supervisor的次数为x-a[i]
* n*x-∑a[i]就是所有人除去必须的能打supervisor的次数
* 如果n*x-∑a[i] >= x 那么就ok
* (n-1)*x-∑a[i]>=0就好
*x>=∑a[i] / (n-1)
*/
int n;
int a[]; public void solve(InputReader in,PrintWriter out) {
n = in.nextInt();
a = new int[N+10];
int ma = 0;
for (int i = 1;i <= n;i++) {
a[i] = in.nextInt();
ma = Math.max(ma,a[i]);
}
long ans;
long sum = 0;
for (int i = 1;i <= n;i++) sum += a[i];
if (sum%(n-1)==0) {
ans = sum/(n-1);
}else {
ans = sum/(n-1) + 1;
}
ans = Math.max(ans, ma);
out.println(ans);
}
} static class InputReader{
public BufferedReader br;
public StringTokenizer tokenizer; public InputReader(InputStream ins) {
br = new BufferedReader(new InputStreamReader(ins));
tokenizer = null;
} public String next(){
while (tokenizer==null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
}catch(IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
} public int nextInt() {
return Integer.parseInt(next());
}
}
}

【Codeforces 348A】Mafia的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  3. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  4. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  5. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  6. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  7. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  8. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

  9. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

随机推荐

  1. css实现左边div固定宽度,右边div自适应撑满剩下的宽度

    (1)使用float <div class="use-float"> <div></div> <div></div> & ...

  2. bzoj 1087: [SCOI2005]互不侵犯King【状压dp】

    显然是状压,设f[i][j][k]为1到i行选j个king,并且第i行状态为k的方案数,判断是否可行然后枚举转移即可 先把可行状态预处理出来会变快 #include<iostream> # ...

  3. BADI FCODE(菜单) 增强

    菜单增强功能只能用于非依赖于过滤器的一次性BADI(不是多用途的). 目前,菜单增强功能只能与程序增强功能(界面)一起创建. 定义一个没有过滤器的一次性增强 2.Classic Badi在FCODE ...

  4. php使用邮箱发送验证码

    如果看着文字眼乏就去看看视频吧-> 如何注册腾讯企业邮箱 https://www.bilibili.com/video/av14351397/ 如何在项目中使用 https://www.bili ...

  5. WKWebView 和 UIWebView 允许背景音乐自动播放(记录)

    WKWebView WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init]; config.allowsInlin ...

  6. Linux安装FTP文档服务器

    1.检查是否安装 了vsftpd,如果未安装 则安装vsftpd. 1)查看系统中是否安装了vsftpd,可以通过执行命令 :rpm -qa | grep vsftpd 2)如果没有安装 vsftpd ...

  7. jquery 菜单展开与收缩参考脚本

    /* * metismenu - v1.1.3 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onoku ...

  8. 405 Convert a Number to Hexadecimal 数字转换为十六进制数

    给定一个整数,编写一个算法将这个数转换为十六进制数.对于负整数,我们通常使用 补码运算 方法.注意:    十六进制中所有字母(a-f)都必须是小写.    十六进制字符串中不能包含多余的前导零.如果 ...

  9. Modbus通讯协议简介

    Modbus协议简介 Modbus协议最初由Modicon公司开发出来,此协议支持传统的RS-232.RS-422.RS-485和以太网设备,许多工业设备,包括PLC,DCS,智能仪表等都在使用Mod ...

  10. struts2之actionSupport学习

    actionSupport在手工完成字段验证,显示错误消息,国际化等情况下推荐使用.