Submission #1297004

#TimeUsernameProblemLanguageResultExecution timeMemory
1297004m_a_dPeru (RMI20_peru)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "peru.h" using namespace std; #define int long long const int MOD=1e9+7; //Hatayı bul (bir ara) int mod_expo(int a, int e) { if(e==0) return 1; if(e==1) return a; int val=mod_expo(a/2, e); int extra; a%2==1 ? extra=a : extra=1; return (((val*val) % MOD)*extra) % MOD; } int32_t solve(int32_t n, int32_t k, int32_t* arr) { /*int n, k; cin >> n >> k;*/ int exponents[n]; exponents[0]=1; for(int i=1; i<n; ++i) exponents[i]=(exponents[i-1]*23) % MOD; /*int arr[n]; for(int i=0; i<n; ++i) cin >> arr[i];*/ vector<vector<int>> dp(n, vector<int>(k, INT64_MAX)); dp[0][0]=arr[0]; for(int j=1; j<k; ++j) { dp[0][j]=max(dp[0][j-1], arr[j]); } for(int i=1; i<n; ++i) { int st_val=INT64_MAX; for(int j=0; j<k; ++j) { if(i-1-j<0) break; st_val=min(st_val, dp[i-1-j][j]); } int add=arr[i]; for(int j=0; j<k; ++j) { if(i+j>=n) break; add=max(add, arr[i+j]); dp[i][j]=st_val+add; } } /*for(int i=0; i<n; ++i) { for(int j=0; j<k; ++j) { cout << dp[i][j] << " "; } cout << endl; }*/ int ans[n]; fill(ans, ans+n, INT64_MAX); int mod_ans=0; for(int i=0; i<n; ++i) { for(int j=0; j<k; ++j) { if(i-j<0) break; ans[i]=min(ans[i], dp[i-j][j]); } } for(int i=0; i<n; ++i) { mod_ans+=(ans[i]*exponents[n-i-1])%MOD; while(mod_ans>=MOD) mod_ans-=MOD; } return mod_ans; }

Compilation message (stderr)

peru.cpp: In function 'int32_t solve(int32_t, int32_t, int32_t*)':
peru.cpp:32:21: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int32_t&)'
   32 |         dp[0][j]=max(dp[0][j-1], arr[j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from peru.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
peru.cpp:32:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   32 |         dp[0][j]=max(dp[0][j-1], arr[j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
peru.cpp:32:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   32 |         dp[0][j]=max(dp[0][j-1], arr[j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
peru.cpp:32:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |         dp[0][j]=max(dp[0][j-1], arr[j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
peru.cpp:32:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |         dp[0][j]=max(dp[0][j-1], arr[j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
peru.cpp:43:20: error: no matching function for call to 'max(long long int&, int32_t&)'
   43 |             add=max(add, arr[i+j]);
      |                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
peru.cpp:43:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   43 |             add=max(add, arr[i+j]);
      |                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
peru.cpp:43:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   43 |             add=max(add, arr[i+j]);
      |                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
peru.cpp:43:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |             add=max(add, arr[i+j]);
      |                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
peru.cpp:43:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |             add=max(add, arr[i+j]);
      |                 ~~~^~~~~~~~~~~~~~~