답안 #821032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
821032 2023-08-11T07:04:29 Z Sandarach151 Magneti (COCI21_magneti) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

const long long MODD = 1e9+7;

long long gett(vector<vector<long long>>& temp, long long i, long long j){
    if(i<0 || j<0){
        return 0;
    }
    else{
        return temp[i][j];
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n, l;
    cin >> n >> l;
    long long arr[n];
    for(long long i=0; i<n; i++){
        cin >> arr[i];	
    }
    sort(arr, arr+n);
    vector<vector<long long>> ans(n, vector<long long>(l+1));
    vector<vector<long long>> pref(n, vector<long long>(l+1));    
    for(long long i=1; i<=l; i++){
        ans[0][i]=i;
        pref[0][i]=(gett(pref, 0, i-1)+ans[0][i])%MODD;
    }
    for(long long i=1; i<n; i++){
        for(long long j=0; j<=l; j++){
            ans[i][j]=2*(gett(pref, i-1, j-arr[i])-gett(pref, i-1, j-2*arr[i]+1))+(max(0, j-2*arr[i]+2))*(gett(ans, i-1, j-2*arr[i]+1));
            ans[i][j]%=MODD;
            pref[i][j]=gett(pref, i, j-1)+ans[i][j];
            pref[i][j]%=MODD;
        }
    }
    cout << ans[n-1][l] << '\n';
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:33:103: error: no matching function for call to 'max(int, long long int)'
   33 |             ans[i][j]=2*(gett(pref, i-1, j-arr[i])-gett(pref, i-1, j-2*arr[i]+1))+(max(0, j-2*arr[i]+2))*(gett(ans, i-1, j-2*arr[i]+1));
      |                                                                                                       ^
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 Main.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:
Main.cpp:33:103: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |             ans[i][j]=2*(gett(pref, i-1, j-arr[i])-gett(pref, i-1, j-2*arr[i]+1))+(max(0, j-2*arr[i]+2))*(gett(ans, i-1, j-2*arr[i]+1));
      |                                                                                                       ^
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 Main.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:
Main.cpp:33:103: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |             ans[i][j]=2*(gett(pref, i-1, j-arr[i])-gett(pref, i-1, j-2*arr[i]+1))+(max(0, j-2*arr[i]+2))*(gett(ans, i-1, j-2*arr[i]+1));
      |                                                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.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:
Main.cpp:33:103: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |             ans[i][j]=2*(gett(pref, i-1, j-arr[i])-gett(pref, i-1, j-2*arr[i]+1))+(max(0, j-2*arr[i]+2))*(gett(ans, i-1, j-2*arr[i]+1));
      |                                                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.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:
Main.cpp:33:103: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |             ans[i][j]=2*(gett(pref, i-1, j-arr[i])-gett(pref, i-1, j-2*arr[i]+1))+(max(0, j-2*arr[i]+2))*(gett(ans, i-1, j-2*arr[i]+1));
      |                                                                                                       ^