Submission #172986

# Submission time Handle Problem Language Result Execution time Memory
172986 2020-01-02T22:58:41 Z FieryPhoenix Rice Hub (IOI11_ricehub) C++11
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <climits>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007

int besthub(int R, int L, int x[], ll B){
  int X[R+1];
  ll ans=1;
  for (int i=1;i<=R;i++)
    X[i]=x[i-1];
  ll r=1,mid=1,cost=0;
  for (int i=1;i<=R;i++){
    while (r<=R && cost<=B){
      r++;
      if (r>R)
	break;
      int newMid=(i+r)/2;
      //cout<<mid<<' '<<newMid<<endl;
      if (newMid==mid)
	cost+=X[r]-X[mid];
      else{
        ll diff=X[newMid]-X[mid];
	cost+=(mid-i+1)*diff;
	cost-=(r-1-newMid+1)*diff;
	cost+=X[r]-X[newMid];
	mid=newMid;
      }
    }
    ans=max(ans,r-i);
    //cout<<"RANGE "<<i<<' '<<r<<" cost "<<cost<<endl;
    int newMid=(i+1+r)/2;
    //cout<<mid<<' '<<newMid<<endl;
    if (newMid==mid)
      cost-=(X[mid]-X[i]);
    else{
      ll diff=X[newMid]-X[mid];
      cost+=(mid-(i+1)+1)*diff;
      cost-=(min(r,R)-newMid+1)*diff;
      cost-=(X[mid]-X[i]);
      mid=newMid;
    }
  }
  return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:63:21: error: no matching function for call to 'min(ll&, int&)'
       cost-=(min(r,R)-newMid+1)*diff;
                     ^
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/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
ricehub.cpp:63:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
       cost-=(min(r,R)-newMid+1)*diff;
                     ^
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/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
ricehub.cpp:63:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
       cost-=(min(r,R)-newMid+1)*diff;
                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from ricehub.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
ricehub.cpp:63:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
       cost-=(min(r,R)-newMid+1)*diff;
                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from ricehub.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
ricehub.cpp:63:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
       cost-=(min(r,R)-newMid+1)*diff;
                     ^