Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static long[] planting(Event[] events) {
- TreeSet<Long> Tree = new TreeSet<Long>();
- for(int i = 0; i<events.length; i++){
- if(events[i].action.equals("kihajt") && !Tree.contains(events[i].position)){
- if(Tree.ceiling(events[i].position) != null){
- if((events[i].position - Tree.ceiling(events[i].position) >= 250)){
- Tree.add(events[i].position);
- }
- }else Tree.add(events[i].position);
- if(Tree.floor(events[i].position) != null){
- if((events[i].position - Tree.floor(events[i].position) >= 250)){
- Tree.add(events[i].position);
- }
- }else Tree.add(events[i].position);
- }
- if(events[i].action.equals("villam") && Tree.contains(events[i].position)){
- Tree.remove(events[i].position);
- }
- }
- long[] ret = new long[Tree.size()];
- for (Long elem: Tree) {
- ret[Tree.headSet(elem).size()] = elem;
- }
- for (Long elem: Tree) {
- System.out.println(elem);
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement