Submission #1247881

#TimeUsernameProblemLanguageResultExecution timeMemory
1247881LM1쌀 창고 (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include "ricehub.h" #include <stdio.h> #include <stdlib.h> #include<bits/stdc++.h> #define MAX_R 1000000 using namespace std; const int N=1e5+5; static int R, L; static long long B; static int X[MAX_R]; static int solution; long long pr[N],ans=-1e18; inline void my_assert(int e) {if (!e) abort();} int solve(int l){ int l1=l,r1=R; while(l1<r1){ int mid=(l1+r1+1)/2,k=(l+mid)/2; if(X[k-1]*(k-l+1)-(pr[k]-pr[l-1])+(pr[mid]-pr[k])-(mid-k)*X[k-1]>B)r1=mid-1; else l1=mid; } return l1-l+1; } int besthub(int R,int L,int X[],int B){ for(int i=0;i<R;i++)pr[i+1]+=pr[i]+X[i]; for(int i=1;i<=R;i++)ans=max(solve(i),ans); return ans; } static void read_input() { int i; my_assert(3==scanf("%d %d %lld",&R,&L,&B)); for(i=0; i<R; i++) my_assert(1==scanf("%d",&X[i])); my_assert(1==scanf("%d",&solution)); } int main() { int ans; read_input(); ans = besthub(R,L,X,B); if(ans==solution) printf("Correct.\n"); else printf("Incorrect. Returned %d instead of %d.\n",ans,solution); return 0; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, int)':
ricehub.cpp:26:37: error: no matching function for call to 'max(int, long long int&)'
   26 |         for(int i=1;i<=R;i++)ans=max(solve(i),ans);
      |                                  ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from ricehub.cpp:4:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
ricehub.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   26 |         for(int i=1;i<=R;i++)ans=max(solve(i),ans);
      |                                  ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from ricehub.cpp:4:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
ricehub.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   26 |         for(int i=1;i<=R;i++)ans=max(solve(i),ans);
      |                                  ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from ricehub.cpp:4:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
ricehub.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |         for(int i=1;i<=R;i++)ans=max(solve(i),ans);
      |                                  ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from ricehub.cpp:4:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
ricehub.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |         for(int i=1;i<=R;i++)ans=max(solve(i),ans);
      |                                  ~~~^~~~~~~~~~~~~~