Submission #1000299

# Submission time Handle Problem Language Result Execution time Memory
1000299 2024-06-17T08:20:38 Z nngan267 Feast (NOI19_feast) C++17
41 / 100
12 ms 27292 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define db long double
#define ii pair<int, int>
#define fi first
#define se second

const int maxn = 2005;
const ll mod = 111539786;
const db eps = -1e9;
const ll inf = 1e18;


int n, k;
int a[maxn];
ll dp[maxn][maxn];
ll s[maxn];

void solve(){
    cin >> n >> k;
    int minn = 1e9;;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        minn = min(minn, a[i]);
        s[i] = s[i-1] + a[i];
    }
    for(int i=1; i<=k; i++){
        ll max_val = 0;
        for(int j=1; j<=n; j++){
            dp[i][j] = dp[i][j-1];
            dp[i][j] = max(dp[i][j], max_val + s[j]);
            max_val = max(max_val, dp[i-1][j] - s[j]);
        }
    }
    if(minn >= 0) dp[k][n] = s[n];
    cout << dp[k][n] << "\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int test = 1;
    while(test--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 436 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 436 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 4700 KB Output is correct
22 Correct 12 ms 27292 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 2 ms 4700 KB Output is correct
25 Correct 3 ms 6748 KB Output is correct
26 Correct 2 ms 4700 KB Output is correct
27 Correct 3 ms 6560 KB Output is correct
28 Correct 1 ms 2652 KB Output is correct
29 Correct 1 ms 2652 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -