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")){
- 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);
- }else Tree.remove(events[i].position);
- }
- long[] ret = new long[Tree.size()];
- int i = 0;
- for (Long elem : Tree) {
- ret[i] = elem;
- i++;
- }
- for (Long elem : Tree) {
- System.out.println(elem);
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement