Submission #852985

# Submission time Handle Problem Language Result Execution time Memory
852985 2023-09-23T09:54:57 Z Abito Homecoming (BOI18_homecoming) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "homecoming.h"
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int NN=1e3+5;
int a[NN],b[NN],n,k,dp[NN][NN],pa[NN],pb[NN];
long long solve(int32_t N, int32_t K, int32_t *A, int32_t *B){
    n=N,k=K;
    for (int i=1;i<=n;i++) a[i]=A[i-1],pa[i]=pa[i-1]+a[i];
    for (int i=1;i<=n;i++) b[i]=B[i-1],pb[i]=pb[i-1]+b[i];
    for (int i=n+1;i<=n+k-1;i++) b[i]=b[i-n],pb[i]=pb[i-1]+b[i];
    int ans=0;
    for (int len=1;len<=n+k-1;len++){
        for (int l=1;l<=n;l++){
            int r=l+len-1;
            if (r>n+k-1) break;
            dp[l][r]=-pb[min(r,l+n-1)]+pb[l-1];
            if (min(r-k+1,l+n-1)>=l) dp[l][r]+=pa[min(r-k+1,l+n-1)]-pa[l-1];
            for (int i=l;i<r;i++) dp[l][r]=max(dp[l][r],dp[l][i]+dp[i+1][r]);
            dp[l][r]=max(dp[l][r],0);
            ans=max(ans,dp[l][r]);
        }
    }return ans;
}

Compilation message

homecoming.cpp: In function 'long long int solve(int32_t, int32_t, int32_t*, int32_t*)':
homecoming.cpp:31:36: error: no matching function for call to 'max(long long int&, int)'
   31 |             dp[l][r]=max(dp[l][r],0);
      |                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from homecoming.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
homecoming.cpp:31:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |             dp[l][r]=max(dp[l][r],0);
      |                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from homecoming.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
homecoming.cpp:31:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |             dp[l][r]=max(dp[l][r],0);
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from homecoming.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
homecoming.cpp:31:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |             dp[l][r]=max(dp[l][r],0);
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from homecoming.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
homecoming.cpp:31:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |             dp[l][r]=max(dp[l][r],0);
      |                                    ^