A problem with MAXSEGM

Can anyone tell me what is the problem with the following code?

import java.io.IOException;
import java.util.Scanner;

class Codechef
{
    public static void main (String[] args) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        long maxsum, x;
        Codechef ob = new Codechef();
        for(int i=1;i<=t;i++) {
            maxsum = 0;
            x = 0;
            int n = sc.nextInt();
            long w[][] = new long[n][2];
            long c[][] = new long[n][2];

            for(int j=0;j<n;j++) {
                c[j][0] = sc.nextInt();
            }

            w[0][0] = sc.nextInt();
            w[0][1] = w[0][0];
            c[0][1] = w[0][0];
            maxsum = w[0][0];
            for(int j=1;j<n;j++) {
                w[j][0] = sc.nextInt();
                w[j][1] = w[j][0] + w[j-1][1];
                int check = ob.searchFor(c, c[j][0], j);
                if(check > -1) {
                    x = w[check][1];
                    c[j][1] = w[j][1] - x;
                } else {
                    c[j][1] = w[j][1] - x;
                }
                if(c[j][1] > maxsum)
                    maxsum = c[j][1];
            }
        
            System.out.println(maxsum);
        }
    }

    int searchFor(long c[][], long num, int j) {
        int i;
        for(i=j-1;i>=0;i--) {
            if(c[i][0] == num)
                break;
        }
        return i;
    }
}

Tested fine against various inputs

Here is the test case-

Input
1
5
0 1 1 0 1
50 60 70 60 90
Output
190
Expected Output
150

This is one of the tricky edge cases here.