-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLemonadeLine.java
More file actions
31 lines (31 loc) · 859 Bytes
/
LemonadeLine.java
File metadata and controls
31 lines (31 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.*;
import java.io.*;
public class LemonadeLine {
public static void main(String[] args) throws IOException
{
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedReader br = new BufferedReader(new FileReader("lemonade.in"));
int num = Integer.parseInt(br.readLine());
String[] temp = br.readLine().split(" ");
int[] tolerance = new int[temp.length];
for (int i = 0; i < temp.length; i++)
{
tolerance[i] = Integer.parseInt(temp[i]);
}
Arrays.sort(tolerance);
int min = tolerance.length;
for (int i = 0; i < tolerance.length; i++)
{
if (tolerance[tolerance.length-1-i] < i)
{
min = i;
break;
}
}
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("lemonade.out")));
pw.println(min);
pw.close();
br.close();
//System.out.println(min);
}
}