其他分享
首页 > 其他分享> > B. Alyona and Mex

B. Alyona and Mex

作者:互联网

 

http://codeforces.com/contest/682/problem/B

 

 

1         //超时
2         int[]a=new int[n];
3         for (int i = 0; i < n; i++) a[i]=io.nextInt();
4         Arrays.sort(a);
5         for (int i = 0; i < n; i++) if (a[i]>=min)min++;

 

 

 1 import java.util.PriorityQueue;
 2 import java.util.Scanner;
 3 
 4 public class Main {
 5     public static void main(String[] args) {
 6         Scanner io = new Scanner(System.in);
 7         int n=io.nextInt(),min=1;
 8         PriorityQueue<Integer>q=new PriorityQueue<>();
 9         for (int i = 0; i < n; i++) q.add(io.nextInt());
10         while (!q.isEmpty()) if (q.poll()>=min)min++;
11         System.out.println(min);
12     }
13 }

 

标签:Alyona,min,int,++,io,new,nextInt,Mex
来源: https://www.cnblogs.com/towerbird/p/11423414.html