2024.3.26
回归蓝桥平台
import java.awt.Checkbox;
import java.awt.PageAttributes.OriginType;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.math.MathContext;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.print.attribute.standard.JobMessageFromOperator;
import javax.print.attribute.standard.ReferenceUriSchemesSupported;
import java.awt.Checkbox;
import java.awt.PageAttributes.OriginType;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.math.MathContext;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.print.attribute.standard.JobMessageFromOperator;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc=new Scanner(System.in);
BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
String[] aStrings=br1.readLine().split(" ");
aa=Integer.parseInt(aStrings[0]);
String[] bStrings=br1.readLine().split(" ");
int a;
for(a=0;a<aa;a++) {
ll1.add(Long.parseLong(bStrings[a]));
}
Collections.sort(ll1);
bb=ll1.get(0);
int b=ll1.size();
long f=0;
while(true) {
long e=0;
while(true) {
if(ll1.size()==0||ll1.get(0)>bb) {
break;
}
if(ll1.get(0)==bb) {
e++;
ll1.remove();
}
}
f=f+e;
if(f%(bb+1)==0) {
f=f/(bb+1);
bb++;
}
else {
break;
}
}
System.out.println(bb);
}
public static int aa;
public static long bb;
public static LinkedList<Long> ll1=new LinkedList<>();
}