【Codeforces 348A】Mafia
【链接】 我是链接,点我呀:)
【题意】
【题解】
```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());
}
}
}