제출 #681917

#제출 시각아이디문제언어결과실행 시간메모리
681917MilosMilutinovicMean (info1cup19_mean)C++14
100 / 100
15 ms524 KiB
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> #include <array> using namespace std; typedef long long ll; const int N = 202; int n; int a[N]; int dp[N][N]; bool was[N][N]; int solve(int l, int r) { if (was[l][r]) return dp[l][r]; was[l][r] = true; if (l == r) return (dp[l][r] = a[l]); for (int i = l; i < r; i++) { dp[l][r] = max(dp[l][r], (solve(l, i) + solve(i + 1, r)) / 2); } return dp[l][r]; } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); printf("%d\n", solve(0, n - 1)); return 0; }

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

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