Submission #729995

# Submission time Handle Problem Language Result Execution time Memory
729995 2023-04-25T03:45:04 Z rahulverma Karte (COCI18_karte) Java 11
12 / 120
1000 ms 35364 KB
import java.io.*;
import java.util.*;

public class karte {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		Integer[] og = new Integer[n];
		for(int i = 0; i < n; i++) og[i] = s.nextInt();
		Arrays.sort(og, Collections.reverseOrder());
		Integer[] arr = new Integer[k];
		for(int i = 0; i < k; i++) {
			arr[i] = og[i];
		}
		Arrays.sort(og);
		Arrays.sort(arr);
		Integer[] arr2 = new Integer[n - k];
		for(int i = 0; i < n - k; i++) {
			arr2[i] = og[i];
		}
		Arrays.sort(arr2);
		
		int falses = 0;
		for(int i = 0; i < n; i++) {
			if(i < k) {
				if(falses < arr[i]) {
					falses++;
				}
			}
			else {
				if(falses < arr2[i - k]) {
					falses++;
				}
			}
		}
		if(falses == k) {
			for(int v: arr) System.out.print(v + " ");
			for(int v: arr2) System.out.print(v + " ");
		}
		else {
			System.out.println(-1);
		}
		
	}

}
# Verdict Execution time Memory Grader output
1 Correct 132 ms 11760 KB Output is correct
2 Correct 95 ms 10272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 11080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 ms 10916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 242 ms 13076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 253 ms 13008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 368 ms 13588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 338 ms 13568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 21464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 23792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 35364 KB Time limit exceeded
2 Halted 0 ms 0 KB -