Submission #1090872

# Submission time Handle Problem Language Result Execution time Memory
1090872 2024-09-19T01:34:13 Z eltu0815 Chorus (JOI23_chorus) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define MAX 300005
#define MOD (ll)(1048573)
#define INF (ll)(1e18)
#define inf (int)(1e9)
#define eps (double)(1e-8)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
int tt, n, m, k, q;
string str;

ll cnt[MAX], sum[MAX], pos[MAX];
ll dp[5005][5005];
ll cost(int i, int j) {
    ll ret = 0;
    for(int k = i; k <= j; ++k) {
        ret += max(0, - (i - 1) + cnt[k]);
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    
    cin >> n >> k >> str;
    for(int i = 0, tmp = 0, p = 0; i < 2 * n; ++i) {
        if(str[i] == 'A') cnt[++p] = tmp;
        else ++tmp;
    }
    
    for(int i = 0, j = 1; i <= n; ++i) {
        while(j <= n && cnt[j] < i) ++j;
        pos[i] = max(i + 1, j);
    }
    for(int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + cnt[i];
    
    for(int i = 0; i <= n; ++i) for(int j = 0; j <= k; ++j) dp[i][j] = INF;
    
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= k; ++j) {
        for(int ii = 0; ii < i; ++ii) {
            //if(pos[ii] <= i)
            dp[i][j] = min(dp[i][j], dp[ii][j - 1] + sum[i] - sum[pos[ii] - 1] - (i - pos[ii] + 1) * ii);
            //else dp[i][j] = min(dp[i][j], dp[ii][j - 1]);
        }
    }
    
    cout << dp[n][k];
    return 0;
}

Compilation message

chorus.cpp: In function 'll cost(int, int)':
chorus.cpp:21:41: error: no matching function for call to 'max(int, ll)'
   21 |         ret += max(0, - (i - 1) + cnt[k]);
      |                                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from chorus.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:
chorus.cpp:21:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   21 |         ret += max(0, - (i - 1) + cnt[k]);
      |                                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from chorus.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:
chorus.cpp:21:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   21 |         ret += max(0, - (i - 1) + cnt[k]);
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from chorus.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:
chorus.cpp:21:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         ret += max(0, - (i - 1) + cnt[k]);
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from chorus.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:
chorus.cpp:21:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         ret += max(0, - (i - 1) + cnt[k]);
      |                                         ^