static long solve(int idx, int s, int p, int t, int a[], int b[]) {
if (idx == a.length) {
return 0;
}
if (dp[idx][s] == -1) {
if (a[idx] > b[idx]) {
if (p > 0) {
dp[idx][s] = a[idx] + solve(idx + 1, s, p - 1, t, a, b);
} else {
dp[idx][s] = b[idx] + solve(idx + 1, s, p, t - 1, a, b);
}
} else {
if (t > 0) {
dp[idx][s] = b[idx] + solve(idx + 1, s, p, t - 1, a, b);
} else {
dp[idx][s] = a[idx] + solve(idx + 1, s, p - 1, t, a, b);
}
}
}
return dp[idx][s];
}
c3RhdGljIGxvbmcgc29sdmUoaW50IGlkeCwgaW50IHMsIGludCBwLCBpbnQgdCwgaW50IGFbXSwgaW50IGJbXSkgewogICAgICAgIGlmIChpZHggPT0gYS5sZW5ndGgpIHsKICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgICAgIGlmIChkcFtpZHhdW3NdID09IC0xKSB7CiAgICAgICAgICAgIGlmIChhW2lkeF0gPiBiW2lkeF0pIHsKICAgICAgICAgICAgICAgIGlmIChwID4gMCkgewogICAgICAgICAgICAgICAgICAgIGRwW2lkeF1bc10gPSBhW2lkeF0gKyBzb2x2ZShpZHggKyAxLCBzLCBwIC0gMSwgdCwgYSwgYik7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGRwW2lkeF1bc10gPSBiW2lkeF0gKyBzb2x2ZShpZHggKyAxLCBzLCBwLCB0IC0gMSwgYSwgYik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBpZiAodCA+IDApIHsKICAgICAgICAgICAgICAgICAgICBkcFtpZHhdW3NdID0gYltpZHhdICsgc29sdmUoaWR4ICsgMSwgcywgcCwgdCAtIDEsIGEsIGIpOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBkcFtpZHhdW3NdID0gYVtpZHhdICsgc29sdmUoaWR4ICsgMSwgcywgcCAtIDEsIHQsIGEsIGIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBkcFtpZHhdW3NdOwogICAgfQ==
Main.java:1: error: class, interface, or enum expected
static long solve(int idx, int s, int p, int t, int a[], int b[]) {
^
Main.java:4: error: class, interface, or enum expected
}
^
Main.java:9: error: class, interface, or enum expected
} else {
^
Main.java:11: error: class, interface, or enum expected
}
^
Main.java:15: error: class, interface, or enum expected
} else {
^
Main.java:17: error: class, interface, or enum expected
}
^
Main.java:21: error: class, interface, or enum expected
}
^
7 errors