Submission #1080965

#TimeUsernameProblemLanguageResultExecution timeMemory
1080965horiaboeriuMean (info1cup19_mean)C++17
100 / 100
3 ms576 KiB
#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)

mean.cpp: In function 'int main()':
mean.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
mean.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d", &dp[i][i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...