// Codeforces Round #159 (Div. 2) A - Sockets
import java.io.*;
import java.math.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
//codeforces
public class MainCodeforces1 {
private static MyScanner in;
private static PrintStream out;
public static void main(String[] args) throws IOException {
// helpers for input/output
boolean LOCAL_TEST = false;
// LOCAL_TEST = true;// comment it before submitting
out = System.out;
if (LOCAL_TEST) {
in = new MyScanner("E:\\zin2.txt");
}
else {
boolean usingFileForIO = false;
if (usingFileForIO) {
// using input.txt and output.txt as I/O
in = new MyScanner("input.txt");
out = new PrintStream("output.txt");
}
else {
in = new MyScanner();
out = System.out;
}
}
solve();
}
private static void solve() throws IOException
{
int N = in.nextInt();
int M = in.nextInt();
int K = in.nextInt();
Integer[] A = new Integer[N];
for (int i = 0; i < A.length; i++) {
A[i] = in.nextInt();
}
Arrays.sort(A, Collections.reverseOrder());
int nsockets = K;
if (nsockets >= M)
{
out.println(0);
return;
}
for (int i = 0; i < N; i++) {
nsockets += A[i] - 1;
if (nsockets >= M)
{
out.println(i + 1);
return;
}
}
out.println(-1);
}
// =====================================
static class MyScanner {
Scanner inp = null;
public MyScanner() throws IOException
{
inp = new Scanner(System.in);
}
public MyScanner(String inputFile) throws IOException {
inp = new Scanner(new FileInputStream(inputFile));
}
public int nextInt() throws IOException {
return inp.nextInt();
}
public long nextLong() throws IOException {
return inp.nextLong();
}
public double nextDouble() throws IOException {
return inp.nextDouble();
}
public String nextString() throws IOException {
return inp.next();
}
}
}
No comments:
Post a Comment