제출 #365069

#제출 시각아이디문제언어결과실행 시간메모리
365069saleh수열 (APIO14_sequence)C++17
컴파일 에러
0 ms0 KiB
//#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 100 * 1000 + 2, MAXK = 200 + 2; int n, k, dp[2 + 2][MAXN], ps[MAXN], a[MAXN], chi, lvl; int32_t par[MAXK][MAXN]; void cal(int l = chi, int r = n + 1, int ll = chi, int rr = n) { int mid = ((l + r) >> 1), md = -1; for (int i = ll; i < mid && i < r; i++) { if (dp[1 - lvl][i] + ps[i] * (ps[mid] - ps[i]) > dp[lvl][mid]) { dp[lvl][mid] = dp[1 - lvl][i] + ps[i] * (ps[mid] - ps[i]); md = i; } } par[chi][mid] = md; if (l < mid) cal(lvl, l, mid, ll, md); if (mid + 1 < r) cal(lvl, mid + 1, r, md, rr); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; ps[i + 1] = ps[i] + a[i]; } for (int i = 1; i <= k; i++) { chi = i; lvl = i & 1; memset(dp[lvl], -1, sizeof dp[lvl]); cal(); } cout << dp[k & 1][n] << '\n'; while (k > 0) { cout << par[k][n] << ' '; n = par[k][n]; k--; } return 0; }

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

sequence.cpp: In function 'void cal(long long int, long long int, long long int, long long int)':
sequence.cpp:39:38: error: too many arguments to function 'void cal(long long int, long long int, long long int, long long int)'
   39 |  if (l < mid) cal(lvl, l, mid, ll, md);
      |                                      ^
sequence.cpp:30:6: note: declared here
   30 | void cal(int l = chi, int r = n + 1, int ll = chi, int rr = n) {
      |      ^~~
sequence.cpp:40:46: error: too many arguments to function 'void cal(long long int, long long int, long long int, long long int)'
   40 |  if (mid + 1 < r) cal(lvl, mid + 1, r, md, rr);
      |                                              ^
sequence.cpp:30:6: note: declared here
   30 | void cal(int l = chi, int r = n + 1, int ll = chi, int rr = n) {
      |      ^~~