제출 #1075517

#제출 시각아이디문제언어결과실행 시간메모리
1075517raduvMean (info1cup19_mean)C++17
100 / 100
2 ms604 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200;
int dp[MAXN + 1][MAXN + 1]; // dp[i][j] = maximul dupa aplicarea operatiilor pentru subsecv (i, j)
int v[MAXN + 1];
int main() {
  int n, i, j, k;
  scanf("%d", &n);
  for( i = 1; i <= n; i++ ){
    scanf("%d", &v[i]);
    dp[i][i] = v[i];
  }
  for( i = 1; i <= n; i++ ){
    for( j = i + 1; j <= n; j++ ){
      for( k = j - i; k <= j; k++ ){
        dp[j - i][j] = max(dp[j - i][j], (dp[j - i][k] + dp[k + 1][j]) / 2);
      }
    }
  }
  printf("%d\n", dp[1][n]);
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

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