Submission #289701

# Submission time Handle Problem Language Result Execution time Memory
289701 2020-09-02T23:01:32 Z b00n0rp Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
#define pb push_back
#define INF 1000000000
#define mp make_pair
#define MOD 1000000007
#define F first
#define S second
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPD(i,n) for(int i=(n);i>=0;i--)
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define all(v) v.begin(),v.end()
#define itr ::iterator it;
#define WL(t) while(t --)

ll r,l,b;
ll a[1000005];
ll pref[1000005];
ll ans = 0;

ll cost(int s, int e){ // s -> start    e -> end     m -> mid
    int m = (s+e)/2; 
    return (a[m]*(m-s))-(pref[m]-pref[s])+(pref[e+1]-pref[m+1])-(a[m]*(e-m));
}


ll besthub(int R, int L, int X[], ll B){
    r = R;
    l = L;
    b = B;

    pref[0] = 0;
    REP(i,r){
        a[i] = X[i];
        pref[i+1] = pref[i]+a[i];
    }
    int low = 0,high = 0;
    while (high < r){
        ll cur = cost(low,high); 
       // cout << low << " " << high << " " << cur << endl;
        if (cur <= b){
            ans = max(ans,high-low+1);
            high ++;
        }
        else{
            low ++;
        }
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'll besthub(int, int, int*, ll)':
ricehub.cpp:54:37: error: no matching function for call to 'max(ll&, int)'
   54 |             ans = max(ans,high-low+1);
      |                                     ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ricehub.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:
ricehub.cpp:54:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   54 |             ans = max(ans,high-low+1);
      |                                     ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ricehub.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:
ricehub.cpp:54:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   54 |             ans = max(ans,high-low+1);
      |                                     ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ricehub.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:
ricehub.cpp:54:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 |             ans = max(ans,high-low+1);
      |                                     ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ricehub.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:
ricehub.cpp:54:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 |             ans = max(ans,high-low+1);
      |                                     ^