# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
729997 |
2023-04-25T03:59:32 Z |
rahulverma |
Karte (COCI18_karte) |
Java 11 |
|
1000 ms |
32204 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 i = n - 1; i >= 0; i--) System.out.print(cards[i] + " ");
}
else {
System.out.println(-1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
11028 KB |
Output is correct |
2 |
Correct |
102 ms |
10084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
11092 KB |
Output is correct |
2 |
Correct |
108 ms |
9992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
11084 KB |
Output is correct |
2 |
Correct |
107 ms |
10100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
286 ms |
12988 KB |
Output is correct |
2 |
Correct |
190 ms |
11908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
251 ms |
13028 KB |
Output is correct |
2 |
Correct |
189 ms |
11568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
320 ms |
13520 KB |
Output is correct |
2 |
Correct |
305 ms |
13364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
326 ms |
13492 KB |
Output is correct |
2 |
Correct |
272 ms |
13452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
20588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1055 ms |
22496 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1061 ms |
32204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |