# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
729998 |
2023-04-25T04:03:03 Z |
rahulverma |
Karte (COCI18_karte) |
Java 11 |
|
1000 ms |
26892 KB |
import java.io.*;
import java.util.*;
public class karte {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int k = Integer.parseInt(st.nextToken());
Integer[] og = new Integer[n];
for(int i = 0; i < n; i++) og[i] = Integer.parseInt(br.readLine());
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++;
}
PrintWriter pw = new PrintWriter(System.out);
if(falses == k) {
for(int i = n - 1; i >= 0; i--) pw.print(cards[i] + " ");
}
else {
pw.println(-1);
}
pw.close();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
9500 KB |
Output is correct |
2 |
Correct |
66 ms |
8380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
9508 KB |
Output is correct |
2 |
Correct |
62 ms |
8140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
9628 KB |
Output is correct |
2 |
Correct |
55 ms |
8228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
9332 KB |
Output is correct |
2 |
Correct |
83 ms |
8412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
9564 KB |
Output is correct |
2 |
Correct |
71 ms |
8412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
9632 KB |
Output is correct |
2 |
Correct |
85 ms |
8552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
141 ms |
9756 KB |
Output is correct |
2 |
Correct |
87 ms |
8484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
17796 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
19704 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
26892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |