# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1017650 | 2024-07-09T09:19:50 Z | vjudge1 | Feast (NOI19_feast) | Kotlin | 컴파일 오류 |
0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define ld long double #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) signed main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, k; cin >> n >> k; vector<int> A(n + 1); for (int i = 1; i <= n; i++) { cin >> A[i]; } int l = 0, r = 1e18, res = 0; while (l <= r) { int md = (l + r) / 2; vector<array<array<int, 2>, 2>> dp(n + 1); for (int i = 1; i <= n; i++) { if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; dp[i][1][1] = dp[i - 1][0][1] + 1; } if (dp[i - 1][1][0] + A[i] > dp[i][1][0]) { dp[i][1][0] = dp[i - 1][1][0] + A[i]; dp[i][1][1] = dp[i - 1][1][1]; } if (dp[i - 1][0][0] > dp[i][0][0]) { dp[i][0][0] = dp[i - 1][0][0]; dp[i][0][1] = dp[i - 1][0][1]; } if (dp[i - 1][1][0] > dp[i][0][0]) { dp[i][0][0] = dp[i - 1][1][0]; dp[i][0][1] = dp[i - 1][1][1]; } } if (dp.back()[0][0] < dp.back()[1][0]) { swap(dp.back()[0], dp.back()[1]); } if (dp.back()[0][1] <= k) { r = md - 1, res = max(res, dp.back()[0][0] + md * dp.back()[0][1]); } else if (dp.back()[0][1] > k){ l = md + 1; } } cout << res; }
Compilation message
feast.kt:1:1: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:2: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:9: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:10: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:14: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:15: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:19: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:21: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:22: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:1:23: error: expecting a top level declaration #include<bits/stdc++.h> ^ feast.kt:2:1: error: expecting a top level declaration using namespace std; ^ feast.kt:2:7: error: expecting a top level declaration using namespace std; ^ feast.kt:2:17: error: expecting a top level declaration using namespace std; ^ feast.kt:3:1: error: expecting a top level declaration #define int long long ^ feast.kt:3:2: error: expecting a top level declaration #define int long long ^ feast.kt:3:9: error: expecting a top level declaration #define int long long ^ feast.kt:3:13: error: expecting a top level declaration #define int long long ^ feast.kt:3:18: error: expecting a top level declaration #define int long long ^ feast.kt:4:1: error: expecting a top level declaration #define ld long double ^ feast.kt:4:2: error: expecting a top level declaration #define ld long double ^ feast.kt:4:9: error: expecting a top level declaration #define ld long double ^ feast.kt:4:12: error: expecting a top level declaration #define ld long double ^ feast.kt:4:17: error: expecting a top level declaration #define ld long double ^ feast.kt:5:1: error: expecting a top level declaration #define endl '\n' ^ feast.kt:5:2: error: expecting a top level declaration #define endl '\n' ^ feast.kt:5:9: error: expecting a top level declaration #define endl '\n' ^ feast.kt:5:14: error: expecting a top level declaration #define endl '\n' ^ feast.kt:6:1: error: expecting a top level declaration #define FF first ^ feast.kt:6:2: error: expecting a top level declaration #define FF first ^ feast.kt:6:9: error: expecting a top level declaration #define FF first ^ feast.kt:6:12: error: expecting a top level declaration #define FF first ^ feast.kt:7:1: error: expecting a top level declaration #define SS second ^ feast.kt:7:2: error: expecting a top level declaration #define SS second ^ feast.kt:7:9: error: expecting a top level declaration #define SS second ^ feast.kt:7:12: error: expecting a top level declaration #define SS second ^ feast.kt:8:1: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:2: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:9: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:12: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:13: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:14: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:16: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:17: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:18: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:23: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:24: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:25: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:27: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:28: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:29: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:32: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:8:33: error: expecting a top level declaration #define all(a) a.begin(), a.end() ^ feast.kt:9:1: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:2: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:9: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:13: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:14: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:16: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:17: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:18: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:9:28: error: expecting a top level declaration #define mod (ll)(1000000007) ^ feast.kt:11:1: error: expecting a top level declaration signed main() { ^ feast.kt:11:8: error: expecting a top level declaration signed main() { ^ feast.kt:11:12: error: expecting a top level declaration signed main() { ^ feast.kt:11:13: error: expecting a top level declaration signed main() { ^ feast.kt:11:15: error: expecting a top level declaration signed main() { ^ feast.kt:12:30: error: this syntax is reserved for future use; to call a reference, enclose it in parentheses: (foo::bar)(args) ios_base::sync_with_stdio(0);cin.tie(0); ^ feast.kt:14:10: error: expecting an element int n, k; ^ feast.kt:14:10: error: unexpected tokens (use ';' to separate expressions on the same line) int n, k; ^ feast.kt:14:13: error: expecting an element int n, k; ^ feast.kt:15:10: error: expecting an element cin >> n >> k; ^ feast.kt:15:14: error: expecting an element cin >> n >> k; ^ feast.kt:18:14: error: expecting 'in' for (int i = 1; i <= n; i++) { ^ feast.kt:18:15: error: expecting ')' for (int i = 1; i <= n; i++) { ^ feast.kt:18:16: error: expecting an expression for (int i = 1; i <= n; i++) { ^ feast.kt:18:32: error: unexpected tokens (use ';' to separate expressions on the same line) for (int i = 1; i <= n; i++) { ^ feast.kt:19:14: error: expecting an element cin >> A[i]; ^ feast.kt:21:11: error: expecting an element int l = 0, r = 1e18, res = 0; ^ feast.kt:21:13: error: unexpected tokens (use ';' to separate expressions on the same line) int l = 0, r = 1e18, res = 0; ^ feast.kt:21:33: error: expecting an element int l = 0, r = 1e18, res = 0; ^ feast.kt:23:16: error: expecting an element int md = (l + r) / 2; ^ feast.kt:25:33: error: type expected vector<array<array<int, 2>, 2>> dp(n + 1); ^ feast.kt:25:37: error: type expected vector<array<array<int, 2>, 2>> dp(n + 1); ^ feast.kt:26:18: error: expecting 'in' for (int i = 1; i <= n; i++) { ^ feast.kt:26:19: error: expecting ')' for (int i = 1; i <= n; i++) { ^ feast.kt:26:20: error: expecting an expression for (int i = 1; i <= n; i++) { ^ feast.kt:26:36: error: unexpected tokens (use ';' to separate expressions on the same line) for (int i = 1; i <= n; i++) { ^ feast.kt:50:23: error: unexpected tokens (use ';' to separate expressions on the same line) r = md - 1, res = max(res, dp.back()[0][0] + md * dp.back()[0][1]); ^ feast.kt:50:79: error: expecting an element r = md - 1, res = max(res, dp.back()[0][0] + md * dp.back()[0][1]); ^ feast.kt:57:11: error: expecting an element cout << res; ^ feast.kt:57:16: error: expecting an element cout << res; ^ feast.kt:12:5: error: unresolved reference: ios_base ios_base::sync_with_stdio(0);cin.tie(0); ^ feast.kt:12:34: error: unresolved reference: cin ios_base::sync_with_stdio(0);cin.tie(0); ^ feast.kt:14:5: error: unresolved reference: int int n, k; ^ feast.kt:15:5: error: unresolved reference: cin cin >> n >> k; ^ feast.kt:15:17: error: unresolved reference: k cin >> n >> k; ^ feast.kt:17:5: error: unresolved reference: vector vector<int> A(n + 1); ^ feast.kt:17:12: error: unresolved reference: int vector<int> A(n + 1); ^ feast.kt:17:19: error: unresolved reference: n vector<int> A(n + 1); ^ feast.kt:18:21: error: unresolved reference: i for (int i = 1; i <= n; i++) { ^ feast.kt:18:26: error: unresolved reference: n for (int i = 1; i <= n; i++) { ^ feast.kt:18:29: error: unresolved reference: i for (int i = 1; i <= n; i++) { ^ feast.kt:18:29: error: variable expected for (int i = 1; i <= n; i++) { ^ feast.kt:19:9: error: unresolved reference: cin cin >> A[i]; ^ feast.kt:21:5: error: unresolved reference: int int l = 0, r = 1e18, res = 0; ^ feast.kt:22:12: error: unresolved reference: l while (l <= r) { ^ feast.kt:22:17: error: unresolved reference: r while (l <= r) { ^ feast.kt:23:9: error: unresolved reference: int int md = (l + r) / 2; ^ feast.kt:23:19: error: unresolved reference: l int md = (l + r) / 2; ^ feast.kt:23:23: error: unresolved reference: r int md = (l + r) / 2; ^ feast.kt:25:9: error: unresolved reference: vector vector<array<array<int, 2>, 2>> dp(n + 1); ^ feast.kt:25:16: error: unresolved reference: array vector<array<array<int, 2>, 2>> dp(n + 1); ^ feast.kt:25:22: error: unresolved reference: array vector<array<array<int, 2>, 2>> dp(n + 1); ^ feast.kt:25:28: error: unresolved reference: int vector<array<array<int, 2>, 2>> dp(n + 1); ^ feast.kt:25:44: error: unresolved reference: n vector<array<array<int, 2>, 2>> dp(n + 1); ^ feast.kt:26:25: error: unresolved reference: i for (int i = 1; i <= n; i++) { ^ feast.kt:26:30: error: unresolved reference: n for (int i = 1; i <= n; i++) { ^ feast.kt:26:33: error: unresolved reference: i for (int i = 1; i <= n; i++) { ^ feast.kt:26:33: error: variable expected for (int i = 1; i <= n; i++) { ^ feast.kt:27:17: error: unresolved reference: dp if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { ^ feast.kt:27:20: error: unresolved reference: i if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { ^ feast.kt:27:35: error: unresolved reference: md if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { ^ feast.kt:27:40: error: unresolved reference: A if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { ^ feast.kt:27:42: error: unresolved reference: i if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { ^ feast.kt:27:47: error: unresolved reference: dp if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { ^ feast.kt:27:50: error: unresolved reference: i if (dp[i - 1][0][0] - md + A[i] > dp[i][1][0]) { ^ feast.kt:28:17: error: unresolved reference: dp dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; ^ feast.kt:28:20: error: unresolved reference: i dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; ^ feast.kt:28:31: error: unresolved reference: dp dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; ^ feast.kt:28:34: error: unresolved reference: i dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; ^ feast.kt:28:49: error: unresolved reference: md dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; ^ feast.kt:28:54: error: unresolved reference: A dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; ^ feast.kt:28:56: error: unresolved reference: i dp[i][1][0] = dp[i - 1][0][0] - md + A[i]; ^ feast.kt:29:17: error: unresolved reference: dp dp[i][1][1] = dp[i - 1][0][1] + 1; ^ feast.kt:29:20: error: unresolved reference: i dp[i][1][1] = dp[i - 1][0][1] + 1; ^ feast.kt:29:31: error: unresolved reference: dp dp[i][1][1] = dp[i - 1][0][1] + 1; ^ feast.kt:29:34: error: unresolved reference: i dp[i][1][1] = dp[i - 1][0][1] + 1; ^ feast.kt:31:17: error: unresolved reference: dp if (dp[i - 1][1][0] + A[i] > dp[i][1][0]) { ^ feast.kt:31:20: error: unresolved reference: i if (dp[i - 1][1][0] + A[i] > dp[i][1][0]) { ^ feast.kt:31:35: error: unresolved reference: A if (dp[i - 1][1][0] + A[i] > dp[i][1][0]) { ^ feast.kt:31:37: error: unresolved reference: i if (dp[i - 1][1][0] + A[i] > dp[i][1][0]) { ^ feast.kt:31:42: error: unresolved reference: dp if (dp[i - 1][1][0] + A[i] > dp[i][1][0]) { ^ feast.kt:31:45: error: unresolved reference: i if (dp[i - 1][1][0] + A[i] > dp[i][1][0]) { ^ feast.kt:32:17: error: unresolved reference: dp dp[i][1][0] = dp[i - 1][1][0] + A[i]; ^ feast.kt:32:20: error: unresolved reference: i dp[i][1][0] = dp[i - 1][1][0] + A[i]; ^ /var/local/l