Submission #660340

# Submission time Handle Problem Language Result Execution time Memory
660340 2022-11-21T17:01:17 Z leroycut Split the sequence (APIO14_sequence) C++17
0 / 100
2000 ms 3652 KB
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
 
const int N = 1e5 + 3;
const ll INF = 2e12 + 3;

int n, k;
ll dp[N][203], p[N];
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    cin >> n >> k;
    for(int i = 1; i <= n; ++i){
        ll a;
        cin >> a;
        p[i] = p[i - 1] + a;
    }

    for(int i = 1; i <= n; ++i){
        for(int j = 1; j < i; ++j){
            for(int t = 1; t < i; ++t){
                dp[i][j] = max(dp[i][j], dp[t][j - 1] + p[t] * (p[i] - p[t]));
            }
        }
    }

    ll cur = dp[n][k];
    cout << cur << "\n";
    int poi = n - 1, end = n, cnt = k - 1;
    for(; poi >= 1 && cnt > 0; --poi){
        if(dp[poi][cnt] + p[poi] * (p[end] - p[poi]) == dp[end][cnt + 1]){
            cout << poi << " ";
            end = poi;
            cnt--;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 596 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 535 ms 1876 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2064 ms 2976 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2086 ms 3652 KB Time limit exceeded
2 Halted 0 ms 0 KB -