# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080965 | horiaboeriu | Mean (info1cup19_mean) | C++17 | 3 ms | 576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <stdlib.h>
#define MAXN 200
int dp[MAXN][MAXN];//dp[i][j] este media aritmetica maxima care se poate forma pe secventa de la i la j
int calc(int x, int y) {
return (x + y) / 2;
}
int main()
{
int n, i, x, j, k, s;
scanf("%d", &n);
//complexitate O(n^3)
for (i = 0; i < n; i++) {
scanf("%d", &dp[i][i]);
}
for (x = 2; x <= n; x++) {//lungimea secventei
for (i = 0; i <= n - x; i++) {//inceputul secventei
j = i + x - 1;
for (k = i; k < j; k++) {
s = calc(dp[i][k], dp[k + 1][j]);
if (s > dp[i][j]) {
dp[i][j] = s;
}
}
}
}
printf("%d\n", dp[0][n - 1]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |