Submission #259738

# Submission time Handle Problem Language Result Execution time Memory
259738 2020-08-08T12:38:46 Z uacoder123 Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;

int besthub(int R, int L, int X[], long long B)
{ 
  lli n=R,ls=0,us=0;
  int l=0,u=-1,m=0;
  lli ans=0;
  for(lli i=0;i<n;++i)
  {
    u++;
    us+=X[i];
    if((u-m+1)>=(m-l)+2)
    {
      ls+=X[m];
      us-=X[m];
      m++;
    }
    while(X[m]*(m-l)-ls+us-X[M]*(u-m+1)>B)
    {
      ls-=X[l];
      l++;
      if((u-m+1)>=(m-l)+2)
      {
        ls+=X[m];
        us-=X[m];
        m++;
      }
    }
    ans=max(ans,u-l+1);
  }
  return(ans);
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:34:30: error: 'M' was not declared in this scope
     while(X[m]*(m-l)-ls+us-X[M]*(u-m+1)>B)
                              ^
ricehub.cpp:45:22: error: no matching function for call to 'max(lli&, int)'
     ans=max(ans,u-l+1);
                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
     ans=max(ans,u-l+1);
                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
     ans=max(ans,u-l+1);
                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
     ans=max(ans,u-l+1);
                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
     ans=max(ans,u-l+1);
                      ^