Cooling Pies - wrong answer

Hi, I am trying to solve this however I am always getting a wrong answer, but every test case i tried worked. Is my logic flawed? I am sorting arrays with pies and weights, and once that is done, i do a comparison, where if a smallest rack is bigger than smallest pie, answer is incremented, and counter goes to the next rack.
Here is my solution: this

Thank you

You are ignoring the case what will happen if a pie is larger than the weight. You need to skip to the next one and check in such scenario. Your inner loop should have taken care of this.

private static void usporedba(int[] arr1, int[] arr2, int length) {

    int rez = 0;
    int j=0; // we need it for the modification 
    for (int i = 0; i < length;i++ ) {
        /*Extra block recalculates and hence wrong answer
        for (int j = 0; j < length; j++) {
            if (arr1[j] >= arr2[i]) {
                if(i+1<=length) i++;
  		j++; 			if (j<length){
  		j++; 			}

This modification of your code lead to acceptance of the code, see it here.

Genious! Thanks