long dp[],array[];
long rec(int i,int prv){ // 0-> len turn, 1--
if ( i >= array.length )
return 0;
if ( dp[i] != -1 )
return dp[i];
if ( i == array.length - 3 ) {
dp[i] = array[i] + array[i+1] + array[i+2];
}
else if ( i == array.length - 2 ) {
dp[i] = array[i] + array[i+1];
}
else if ( i == array.length - 1 ) {
dp[i] = array[i];
}
else {
dp[i] =max( max(
rec(i+2 , array.length) + array[i] ,
rec(i+4 , array.length) + array[i] + array[i+1]),
rec(i+6 , array.length) + array[i] + array[i+1] + array[i+2] );
} return dp[i];
}
ICAgIGxvbmcgZHBbXSxhcnJheVtdOwogICAgbG9uZyByZWMoaW50IGksaW50IHBydil7ICAgICAgICAgICAgICAgIC8vIDAtPiBsZW4gdHVybiwgMS0tCiAgICAgICAgaWYgKCBpID49IGFycmF5Lmxlbmd0aCApCiAgICAgICAgICAgIHJldHVybiAwOwogCiAgICAgICAgaWYgKCBkcFtpXSAhPSAtMSApCiAgICAgICAgICAgIHJldHVybiBkcFtpXTsKIAogICAgICAgIGlmICggaSA9PSBhcnJheS5sZW5ndGggLSAzICkgewogICAgICAgICAgICBkcFtpXSA9IGFycmF5W2ldICsgYXJyYXlbaSsxXSArIGFycmF5W2krMl07CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKCBpID09IGFycmF5Lmxlbmd0aCAtIDIgKSB7CiAgICAgICAgICAgIGRwW2ldID0gYXJyYXlbaV0gKyBhcnJheVtpKzFdOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmICggaSA9PSBhcnJheS5sZW5ndGggLSAxICkgewogICAgICAgICAgICBkcFtpXSA9IGFycmF5W2ldOwogICAgICAgIH0KICAgICAgICBlbHNlIHsKICAgICAgICAgICAgZHBbaV0gPW1heCggbWF4KAogICAgICAgICAgICAgICAgICAgIHJlYyhpKzIgLCBhcnJheS5sZW5ndGgpICsgYXJyYXlbaV0gLAogICAgICAgICAgICAgICAgICAgIHJlYyhpKzQgLCBhcnJheS5sZW5ndGgpICsgYXJyYXlbaV0gKyBhcnJheVtpKzFdKSwKICAgICAgICAgICAgICAgICAgICByZWMoaSs2ICwgYXJyYXkubGVuZ3RoKSArIGFycmF5W2ldICsgYXJyYXlbaSsxXSArIGFycmF5W2krMl0gKTsKICAgICAgICB9IHJldHVybiBkcFtpXTsKIAogICAgfQo=
Main.java:1: error: class, interface, or enum expected
long dp[],array[];
^
Main.java:2: error: class, interface, or enum expected
long rec(int i,int prv){ // 0-> len turn, 1--
^
Main.java:6: error: class, interface, or enum expected
if ( dp[i] != -1 )
^
Main.java:9: error: class, interface, or enum expected
if ( i == array.length - 3 ) {
^
Main.java:11: error: class, interface, or enum expected
}
^
Main.java:14: error: class, interface, or enum expected
}
^
Main.java:17: error: class, interface, or enum expected
}
^
Main.java:23: error: class, interface, or enum expected
} return dp[i];
^
Main.java:25: error: class, interface, or enum expected
}
^
9 errors