이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
const int nmax = 200;
int dp[nmax + 1][nmax + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ )
cin >> dp[i][i];
for ( int i = 2; i <= n; i++ ) /// lungimea
for ( int j = 1; j <= n - i + 1; j++ ) {
int maxy = 0;
for ( int k = j; k < i + j - 1; k++ )
maxy = max ( maxy, ( dp[j][k] + dp[k + 1][i + j - 1] ) / 2 );
dp[j][i + j - 1] = maxy;
}
cout << dp[1][n];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |