Submission #269803

# Submission time Handle Problem Language Result Execution time Memory
269803 2020-08-17T10:31:04 Z kaplanbar Go (COCI18_go) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Pk {
    int a, b, t;
    bool operator<(const Pk other) const {
        return a < other.a;
    }
};
int n, k, m, sz1, sz2, dp[105][2005];
Pk v1[105],v2[105];
int f(int idx, int T) {
    if(idx>=sz1) return 0;
    if(~dp[idx][T]) return dp[idx][T];
    ll ret=0;
    if(T<v1[idx].t) ret+=v1[idx].b;
    if(idx!=sz1-1) {
        ret+=f(idx+1,T+v1[idx+1].a-v1[idx].a);
    }
    return dp[idx][T]=ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    memset(dp,-1,sizeof dp);
    cin >> n >> k >> m;
    ll ans=0;
    for(int i = 0; i < m; i++) {
        int a, b, t;
        cin >> a >> b >> t;
        if(a==k) {
            ans += b;
            continue;
        }
        if(a>k) v1[sz1++]={a,b,t};
        else v2[sz2++]={a,b,t};
    }
    sort(v1, v1+sz1);
    
    sort(v2, v2+sz2);
    reverse(v2, v2+sz2);

    ans = sz1 ? f(0,v1[0].a-k) : 0;

    ll sum = 0;

    for(int i = 0; i < sz2; i++) {
        if(v2[i].t > k - v2[i].a) {
            sum += v2[i].b;
        }
        ans = max(ans, sum + sz1 ? f(0, k - v2[i].a + v1[0].a - v2[i].a) : 0);
    }

    cout << ans;

    return 0;
}

Compilation message

go.cpp: In function 'int main()':
go.cpp:51:77: error: no matching function for call to 'max(ll&, int)'
   51 |         ans = max(ans, sum + sz1 ? f(0, k - v2[i].a + v1[0].a - v2[i].a) : 0);
      |                                                                             ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from go.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
go.cpp:51:77: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |         ans = max(ans, sum + sz1 ? f(0, k - v2[i].a + v1[0].a - v2[i].a) : 0);
      |                                                                             ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from go.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
go.cpp:51:77: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |         ans = max(ans, sum + sz1 ? f(0, k - v2[i].a + v1[0].a - v2[i].a) : 0);
      |                                                                             ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from go.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
go.cpp:51:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |         ans = max(ans, sum + sz1 ? f(0, k - v2[i].a + v1[0].a - v2[i].a) : 0);
      |                                                                             ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from go.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
go.cpp:51:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |         ans = max(ans, sum + sz1 ? f(0, k - v2[i].a + v1[0].a - v2[i].a) : 0);
      |                                                                             ^