제출 #549977

#제출 시각아이디문제언어결과실행 시간메모리
549977Duy_e수열 (APIO14_sequence)C++14
11 / 100
133 ms131072 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; } 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) << '\n'; go(1, n, k); return 0; } /** /\_/\ * (= ._.) * / >🍵 \>🍮 **/

컴파일 시 표준 에러 (stderr) 메시지

sequence.cpp:61:9: warning: "/*" within comment [-Wcomment]
   61 | /**  /\_/\
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...