Submission #866518

#TimeUsernameProblemLanguageResultExecution timeMemory
866518faricaHomecoming (BOI18_homecoming)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "homecoming.h" #define int long long using namespace std; const int MAX_N=2000000; const int N=1000001; long long int solve(int N, int K, int *A, int *B) { int n=N, k=K; cin >> n >> k; int a[n], b[n], pref[n]; for(int i=0; i<n; ++i) a[i] = A[i]. for(int i=0; i<n; ++i) { b[i] = B[i]; pref[i] = b[i]; if(i) pref[i] += pref[i-1]; } int dp[n][2], ans=0; dp[0][0] = -1e18; dp[0][1] = a[0] - pref[k-1]; for(int i=1; i<n; ++i) { dp[i][0] = max(dp[i-1][0], dp[i-1][1]); int val1 = dp[i-1][1] + a[i]; if((i+k-1)<n) val1 -= b[i+k-1]; int val2 = dp[i-1][0] + a[i] - pref[min(i+k-1, n-1)] + pref[i-1]; dp[i][1] = max(val1,val2); } ans = max(ans, dp[n-1][1]); ans = max(ans, dp[n-1][0]); dp[0][1] = -1e18; dp[0][0] = 0; for(int i=1; i<n; ++i) { dp[i][0] = max(dp[i-1][0], dp[i-1][1]); int val1 = dp[i-1][1] + a[i] - b[(i+k-1)%n]; int val2 = dp[i-1][0] + a[i]; if((i+k-1)<n) val2 -= pref[i+k-1] - pref[i-1]; else val2 -= pref[n-1] - pref[i-1] + pref[(i+k-1)%n]; dp[i][1] = max(val1, val2); } ans = max(ans, dp[n-1][0]); return ans; }

Compilation message (stderr)

homecoming.cpp:3:13: error: 'long long long' is too long for GCC
    3 | #define int long long
      |             ^~~~
homecoming.cpp:10:11: note: in expansion of macro 'int'
   10 | long long int solve(int N, int K, int *A, int *B) {
      |           ^~~
homecoming.cpp:3:18: error: 'long long long' is too long for GCC
    3 | #define int long long
      |                  ^~~~
homecoming.cpp:10:11: note: in expansion of macro 'int'
   10 | long long int solve(int N, int K, int *A, int *B) {
      |           ^~~
homecoming.cpp: In function 'long long int solve(long long int, long long int, long long int*, long long int*)':
homecoming.cpp:15:5: error: expected unqualified-id before 'for'
   15 |     for(int i=0; i<n; ++i) {
      |     ^~~
homecoming.cpp:15:18: error: 'i' was not declared in this scope
   15 |     for(int i=0; i<n; ++i) {
      |                  ^