# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1138100 | secretwood01 | Take-out (POI13_usu) | Java | 0 ms | 0 KiB |
import java.util.*;
import java.io.*;
public class Takeout {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int k = Integer.parseInt(st.nextToken());
st = new StringTokenizer(br.readLine());
char [] a = st.nextToken().toCharArray();
TreeMap<Integer, Ans> ans = new TreeMap<>();
TreeSet<Integer> used = new TreeSet<>();
for (int i=0;i<N;i++) {
if (a[i]=='c') {
ans.put(i, new Ans(i));
}
}
for (int x : ans.keySet()) {
if (x==ans.firstKey()) ans.get(x).prev = -1;
else ans.get(x).prev = ans.lowerKey(x);
}
int currclosest = ans.firstKey();
for (int i=0;i<N;i++) {
if (a[i]=='c') {
currclosest = i;
continue;
}
int ogc = currclosest;