제출 #29509

#제출 시각아이디문제언어결과실행 시간메모리
29509inqr쌀 창고 (IOI11_ricehub)C++14
컴파일 에러
0 ms0 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define rt insert #define st first #define nd second using namespace std; vector < int > presum; vector < long long > presum2; int fienum,ans; long long b; long long sum(int l,int r){ if(l==0)return presum[r]; else return presum[r]-presum[l-1]; } long long comp(int l,int r,int X[]){ long long m=(l+r)/2; long long lc=m-l,rc=r-m; return lc*X[m]-sum(l,m-1)+sum(m+1,r)-rc*X[m]; } void solve(int s,int X[]){ int l=s,r=fienum-1; while(l<=r){ int m=(l+r)/2; //printf("s=%d l=%d r=%d m=%d comp=%d %d\n",s,l,r,m,comp(s,m,X).st,comp(s,m,X).nd); if(comp(s,m,X)<=b){ l=m+1; ans=max(ans,m-s+1); } else r=m-1; } } long long sum2(int l,int r){ if(l==0)return presum2[r]; else return presum2[r]-presum2[l-1]; } long long comp2(int l,int r,int X[]){ long long m=(l+r)/2; long long lc=m-l,rc=r-m; return lc*X[m]-sum2(l,m-1)+sum2(m+1,r)-rc*X[m]; } void solve2(int s,int X[]){ int l=s,r=fienum-1; while(l<=r){ int m=(l+r)/2; //printf("s=%d l=%d r=%d m=%d comp=%d %d\n",s,l,r,m,comp(s,m,X).st,comp(s,m,X).nd); if(comp2(s,m,X)<=b){ l=m+1; ans=max(ans,m-s+1); } else r=m-1; } } int besthub(int R, int L, int X[], long long B) { fienum=R;b=B; presum.resize(R); presum[0]=presum2=X[0]; for(int i=1;i<R;i++){presum[i]=presum[i-1]+X[i];presum2[i]=presum2[i-1]+X[i];} if(R<=5000)for(int i=0;i<R;i++)solve(i,X); else for(int i=0;i<R;i++)solve2(i,X); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:60:22: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'int')
     presum[0]=presum2=X[0];
                      ^
In file included from /usr/include/c++/5/vector:69:0,
                 from /usr/include/c++/5/bits/random.h:34,
                 from /usr/include/c++/5/random:49,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from ricehub.cpp:2:
/usr/include/c++/5/bits/vector.tcc:167:5: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]
     vector<_Tp, _Alloc>::
     ^
/usr/include/c++/5/bits/vector.tcc:167:5: note:   no known conversion for argument 1 from 'int' to 'const std::vector<long long int>&'
In file included from /usr/include/c++/5/vector:64:0,
                 from /usr/include/c++/5/bits/random.h:34,
                 from /usr/include/c++/5/random:49,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from ricehub.cpp:2:
/usr/include/c++/5/bits/stl_vector.h:448:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]
       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
       ^
/usr/include/c++/5/bits/stl_vector.h:448:7: note:   no known conversion for argument 1 from 'int' to 'std::vector<long long int>&&'
/usr/include/c++/5/bits/stl_vector.h:470:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]
       operator=(initializer_list<value_type> __l)
       ^
/usr/include/c++/5/bits/stl_vector.h:470:7: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<long long int>'