Submission #1087242

# Submission time Handle Problem Language Result Execution time Memory
1087242 2024-09-12T11:10:59 Z Thunnus Split the sequence (APIO14_sequence) C++17
0 / 100
2000 ms 15452 KB
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define pii pair<int, int>
#define fi first
#define se second
#define sz(x) (int)(x).size()
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k;
    cin >> n >> k;
    vi a(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] += a[i - 1];
    }
 
    vvi dp(n + 1, vi(k + 2)), from(n + 1, vi(k + 2));
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= k + 1; j++){
            for(int z = 1; z <= i; z++){
                int val = dp[z - 1][j - 1] + (a[i] - a[z - 1]) * (a[n] - a[i]);
                if(val > dp[i][j]){
                    from[i][j] = z;
                    dp[i][j] = val;
                }
            }
        }
    }
 
    cout << dp[n][k + 1] << "\n";
    vi ind;
    for(int i = k, idx = n; i >= 0; i--){
        ind.emplace_back(idx);
        idx = from[idx][i];
    }
    for(int i = sz(ind) - 1; i >= 1; i--){
		cout << ind[i] << " ";
	}
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB contestant found the optimal answer: 108 == 108
2 Incorrect 0 ms 348 KB declared answer doesn't correspond to the split scheme: declared = 999, real = 719
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer 0 violates the range [1, 49]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB declared answer doesn't correspond to the split scheme: declared = 610590000, real = 507121050
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB declared answer doesn't correspond to the split scheme: declared = 21503404, real = 21169074
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 263 ms 1952 KB declared answer doesn't correspond to the split scheme: declared = 1818678304, real = 1396709524
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2020 ms 15452 KB Time limit exceeded
2 Halted 0 ms 0 KB -