# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
828132 | rahulverma | JJOOII 2 (JOI20_ho_t2) | Java | 252 ms | 18440 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.io.*;
import java.util.*;
public class ho_t2 {
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());
PrintWriter pw = new PrintWriter(System.out);
String s = br.readLine();
ArrayList<Integer> J = new ArrayList<Integer>();
ArrayList<Integer> O = new ArrayList<Integer>();
ArrayList<Integer> I = new ArrayList<Integer>();
for(int i = 0; i < n; i++) {
if(s.charAt(i) == 'J') J.add(i);
else if(s.charAt(i) == 'O') O.add(i);
else I.add(i);
}
if(J.size() < k || O.size() < k || I.size() < k) {
pw.println(-1);
pw.close();
return;
}
int[] jPrefix = new int[J.size()];
int[] oPrefix = new int[O.size()];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |