不应该啊,对比好多数据都一样.........
查看原帖
不应该啊,对比好多数据都一样.........
715540
CYHMMZDAN楼主2022/9/10 23:41
```java

import java.io.; import java.io.BufferedReader; import java.lang.reflect.Array; import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.text.Format; import java.text.SimpleDateFormat; import java.util.; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Map; import java.util.HashMap;

public class Main { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static StringBuilder stringBuilder = new StringBuilder(); static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static String s = ""; static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); static int n = 0; static int min = 2000000000; static int sum = 0; static int max = 0; static int m1=0; static int m2=0; static int m = 0; static int ans = 0; static int l = 0; static int r = 0; StringBuilder stringBuilder1=new StringBuilder(); static Map<Integer, Integer> map = new TreeMap<>(); static Map<Integer, Integer> map1 = new TreeMap<>(); static int[] c = new int[100010]; static boolean[] booleans=new boolean[10001]; static int[][] b2 = new int[100][100]; static int[] dp = new int[501000]; static int[][] a2 = new int[2001][2001]; static int[] a=new int[100001]; static int[] b=new int[100001]; static int[] a1={0,1,-1,0,0}; static int[] b1={0,0,0,1,-1}; static String[] s1=new String[1005]; static PriorityQueue xiao = new PriorityQueue(); static PriorityQueue xiao1 = new PriorityQueue(); static PriorityQueue xiao2 = new PriorityQueue(); static PriorityQueue da = new PriorityQueue(Collections.reverseOrder()); public static void main(String[] args) throws IOException { n=Scanf_Int(); int[] a=new int[n]; int[] b=new int[n]; for (int i = 0; i < n; i++) { a[i] = Scanf_Int(); } int v=0,v1=0,ans1=0; Arrays.sort(a); while (ans1!=n) { v=0; v1=0; PriorityQueue da = new PriorityQueue(Collections.reverseOrder()); while (v<b.length) { if (b[v] != -1) { da.add(a[v]); ans1++; b[v] = -1; while (v < a.length - 1 && a[v] == a[v + 1]) { v++; v1 = 1; } v++; } else { v++; } } while (da.size() > 0) { m = 1; m1 = da.poll(); l = 0; while (da.size() > 0) { m2 = da.poll(); if (m1 - m2 == 1) { m++; } else { da.add(m2); break; } m1 = m2; l++; } min = Math.min(min, m); } } out.print(min);

    out.close();
}

public static int gys(int a,int b){
    if (a%b==0){
        return b;
    }
    return gys(b,a%b);
}

public static int gbs(int a,int b){

    return a*b/gys(a,b);

}

public static String oti(long a)
{
    if(a==15)  return "F";
    if(a==14)  return "E";
    if(a==13)  return "D";
    if(a==12)  return "C";
    if(a==11)  return "B";
    if(a==10)  return "A";
    return a+"";
}
public static void zh_ten_qt(long k,int n){
    if (k/n!=0){
        zh_ten_qt(k/n,n);
    }
    out.print(oti(k%n));
}
public static int zh_ten(String s,int n){
    int len=s.length()-1;
    int sum=0,m=0;
    while (len>=0){
        sum+=(zh_zf(s.charAt(len))*Math.pow(n,m));
        len--;
        m++;
    }
    return sum;
}

public static int zh_zf(char c){
    if (c>='0'&&c<='9'){
        return c-48;
    }
    else if (c>='A'&&c<='F'){
        return c-55;
    }
    else {
        return 0;
    }
}

public static boolean pd(int [] h,int n){
    for (int i=1;i<=n;i++){
        if (h[i]<1){
            return false;
        }
        sum+=h[i];
    }
    return true;
}
public static long ks_mod(long a,long b){
    long x=1,y=a;
    while (b>0){
        if ((b&1)==1){
            x*=y;
            x%=m1;
        }
        y*=y;
        y%=m1;
        b>>=1;
    }
    return x;
}
public static int gcd(int i,int j) {
    if (i == 0) {
        return j;
    }
    if (j == 0) {
        return i;
    }
    if (i % j == 0) {
        return j;
    }
    return gcd(j, i % j);

}
public static void dfs(int z,int c) {
    if (z<0||z>n+1||c<0||c>n+1||b2[z][c]!=0){
        return;
    }
    b2[z][c]=1;
    for (int i=1;i<=4;i++){
        dfs(z+a1[i],c+b1[i]);
    }
}
public static String ZH_string(int k){
    for (int i=65;i<=k+65;i++){
        stringBuilder.append((char) i);
    }
    return stringBuilder.toString();
}
public static boolean z_h(char a,char b){
    if ((int) a<(int) b){
        return true;
    }
    else {
        return false;
    }
}
public static int asd(char a,char b){
    for (int i=65;i<91;i++){
        if (a==(char) i&&b==(char) (i+1)){
            return 1;
        }
    }
    return 0;
}
public static double log2(int n){
    return Math.log(n)/Math.log(2);
}
public static void zfcpx(String[] s1,int n){
    for (int i=0;i<n-1;i++){
        for (int j=0;j<n-1-i;j++){
            if (s1[j].compareTo(s1[j+1])>0){
                String s3=s1[j];
                s1[j]=s1[j+1];
                s1[j+1]=s3;
            }
        }
    }
}
public static void zishu(){
    for (int i=2;i<=n;i++){
        if (!booleans[i]) {
            a[++m] = i;
        }
        for (int j=1;j<=m&&a[j]*i<=n;j++){
            booleans[a[j]*i]=true;
            if (i%a[j]==0){
                break;
            }
        }
    }
}
public static void gb(int l,int r){
    if (l==r){
        return;
    }
    int mid=(l+r)/2;
    int z=mid+1,k=l,x=l,p=l;
    gb(l,mid);
    gb(mid+1,r);
    while (k<=mid&&z<=r){
        if (a[k]<=a[z]){
            b[x++]=a[k++];
        }
        else {
            b[x++]=a[z++];
            sum+=mid+1-k;
        }
    }
    while (k<=mid){
        b[x++]=a[k++];
    }
    while (z<=r){
        b[x++]=a[z++];
    }
    for (int i=l;i<=r;i++){
        a[i]=b[i];
    }
}

public static long min(long a, long b) {
    return a < b ? a : b;
}

public static void mp(int[] b, int cc) {
    for (int i = 0; i < cc; i++) {
        for (int j = 0; j < cc - i; j++) {
            if (b[j] > b[j + 1]) {
                int t = b[j];
                b[j] = b[j + 1];
                b[j + 1] = t;
            }
        }
    }
}
public static void cr(long[] a){
    for (int i=1;i<a.length;i++){
        long b=a[i];
        int b1=i-1;
        while (b1>=0&&b>a[b1]){
            a[b1+1]=a[b1];
            b1--;
        }
        a[b1+1]=b;
    }
}
public static int asd(int i) {
    return i * (i - 1) / 2;
}

static int Scanf_Int() throws IOException {
    in.nextToken();
    return (int) in.nval;
}

static long Scanf_Long() throws IOException {
    in.nextToken();
    return (long) in.nval;
}

static double Scanf_Double() throws IOException {
    in.nextToken();
    return in.nval;
}

} class Node implements Comparable { int q,w,e,r;

public Node(int q, int w, int e, int r) {
    this.q = q;
    this.w = w;
    this.e = e;
    this.r = r;
}

@Override
public int compareTo(Node o) {
    if (o.q>this.q){
        return 1;
    }
    else if (o.q<this.q){
        return -1;
    }
    else {
        if (o.r<this.r){
            return 1;
        }
        else {
            return -1;
        }
    }
}

}

2022/9/10 23:41
加载中...