# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
729996 |
2023-04-25T03:57:57 Z |
rahulverma |
Karte (COCI18_karte) |
Java 11 |
|
1000 ms |
32176 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(arr);
int[] cards = new int[n];
for(int i = 0; i < n; i++) {
if(i < k) cards[i] = arr[i];
else cards[i] = og[i];
}
int falses = 0;
for(int i = 0; i < n; i++) {
if(falses < cards[i]) falses++;
}
if(falses == k) {
for(int v: cards) System.out.print(v + " ");
}
else {
System.out.println(-1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
11180 KB |
Output is correct |
2 |
Correct |
107 ms |
10120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
127 ms |
11092 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
141 ms |
10968 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
249 ms |
12940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
265 ms |
12928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
332 ms |
13756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
345 ms |
13652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
20880 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
22624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
32176 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |