Submission #919919

# Submission time Handle Problem Language Result Execution time Memory
919919 2024-02-01T20:41:30 Z divad Mean (info1cup19_mean) C++17
100 / 100
2 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 202;
int n,a[NMAX],dp[NMAX][NMAX];

void maxSelf(auto &a, auto b){
    a = max(a, b);
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i][i] = a[i];
    }
    for(int len = 2; len <= n; len++){
        for(int i = 1; i <= n-len+1; i++){
            int j = i+len-1;
            for(int k = i; k < j; k++){
                maxSelf(dp[i][j], (dp[i][k] + dp[k+1][j])/2);
            }
        }
    }
    cout << dp[1][n];
    return 0;
}

Compilation message

mean.cpp:6:14: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    6 | void maxSelf(auto &a, auto b){
      |              ^~~~
mean.cpp:6:23: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    6 | void maxSelf(auto &a, auto b){
      |                       ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct