Submission #549979

#TimeUsernameProblemLanguageResultExecution timeMemory
549979Duy_eSplit the sequence (APIO14_sequence)C++14
Compilation error
0 ms0 KiB
/* ** TASK: ** LINK: */ #include <bits/stdc++.h> #define ll long long #define pii pair<ll, ll> #define st first #define nd second #define file "test" using namespace std; const long long INF = 1e18; const long long N = 200 + 5; ll n, a[N], k, dp[N][N][N], f[N], trace[N][N][N], num[N][N][N]; ll cal(int l, int r, int cur) { if (l >= r || cur == 0) return 0; if (dp[l][r][cur] != -1) return dp[l][r][cur]; ll &ans = dp[l][r][cur]; ans = 0; for (int i = l; i <= r; i ++) { for (int j = 0; j <= i - l; j ++) if (j < cur && r - i > cur - j - 1) { ll tmp = (f[i] - f[l - 1]) * (f[r] - f[i]) + cal(l, i, j) + cal(i + 1, r, cur - j - 1); if (tmp > ans) trace[l][r][cur] = i, num[l][r][cur] = j, ans = tmp; } } return ans;0p } void go(int l, int r, int cur) { if (trace[l][r][cur] == 0 || cur == 0) return; cout << trace[l][r][cur] << ' '; go(l, trace[l][r][cur], num[l][r][cur]); go(trace[l][r][cur] + 1, r, cur - num[l][r][cur] - 1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // #ifndef ONLINE_JUDGE // freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); // #endif cin >> n >> k; for (int i = 1; i <= n; i ++) cin >> a[i], f[i] = f[i - 1] + a[i]; memset(dp, -1, sizeof dp); cout << cal(1, n, k) + 1<< '\n'; go(1, n, k); return 0; } /** /\_/\ * (= ._.) * / >🍵 \>🍮 **/

Compilation message (stderr)

sequence.cpp:61:9: warning: "/*" within comment [-Wcomment]
   61 | /**  /\_/\
      |          
sequence.cpp: In function 'long long int cal(int, int, int)':
sequence.cpp:33:16: error: unable to find numeric literal operator 'operator""p'
   33 |     return ans;0p
      |                ^~
sequence.cpp:33:16: note: use '-fext-numeric-literals' to enable more built-in suffixes