Submission #333401

# Submission time Handle Problem Language Result Execution time Memory
333401 2020-12-05T20:45:50 Z rocks03 Split the sequence (APIO14_sequence) C++14
0 / 100
2000 ms 1900 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXK = 2e2+10;
const int MAXN = 1e5+100;
int N, K, a[MAXN];
ll pref[MAXN], dp[MAXK][MAXN];

void solve(){
    int N, K;
    cin >> N >> K;
    int a[N]; int pref[N+1];
    pref[0] = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        pref[i+1] = pref[i] + a[i];
    }
    for(int k = 1; k <= K; k++){
        for(int i = 0; i < N; i++){
            for(int j = i+1; j < N; j++){
                ll lt = pref[j] - pref[i], rt = pref[N] - pref[j];
                dp[k][i] = max(dp[k][i], dp[k-1][j] + lt * rt);
            }
        }
    }
    cout << dp[K][0];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Compilation message

sequence.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization("O3")
      | 
sequence.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization("unroll-loops")
      |
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 256 ms 748 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2078 ms 1900 KB Time limit exceeded
2 Halted 0 ms 0 KB -