Submission #886148

#TimeUsernameProblemLanguageResultExecution timeMemory
886148imarnFinancial Report (JOI21_financial)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #define f first #define s second #define ll long long #define pb push_back #define pii pair<ll,ll> #define all(x) x.begin(),x.end() using namespace std; const int N=3e5+5; struct lazy{ ll t[4*N]{0},lz[4*N]{0}; void push(int i,int l,int r){ if(lz[i]){ t[i]=lz[i]; if(l<r){ lz[2*i]=lz[i]; lz[2*i+1]=lz[i]; }lz[i]=0; } } void upd(int i,int l,int r,int tl,int tr,int v){ push(i,l,r); if(r<tl||l>tr)return; if(r<=tr&&l>=tl){ lz[i]=v;push(i,l,r);return; }int m=(l+r)>>1; upd(2*i,l,m,tl,tr,v);upd(2*i+1,m+1,r,tl,tr,v); t[i]=max(t[2*i],t[2*i+1]); } ll qr(int i,int l,int r,int tl,int tr){ push(i,l,r); if(r<tl||l>tr)return 0; if(r<=tr&&l>=tl)return t[i]; int m=(l+r)>>1; return max(qr(2*i,l,m,tl,tr),qr(2*i+1,m+1,r,tl,tr)); } }lt; ll t[2*N]{0}; void upd1(int i,ll amt,int sz){ i+=sz;t[i]=amt; for(i>>=1;i;i>>=1)t[i]=max(t[2*i],t[2*i+1]); } void upd2(int i,ll amt,int sz){ i+=sz;t[i]=max(amt,t[i]); for(i>>=1;i;i>>=1)t[i]=max(t[2*i],t[2*i+1]); } ll qr1(int l,int r,int sz,ll res=0){ for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){ if(l&1)res=max(res,t[l++]); if(r&1)res=max(res,t[--r]); }return res; } vector<ll>co; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); ll n,d;cin>>n>>d; ll a[n+1];ll ans=0; for(int i=1;i<=n;i++)cin>>a[i],co.pb(a[i]); sort(all(co));co.erase(unique(all(co)),co.end());int sz=co.size(); for(int i=1;i<=n;i++){ int id = upper_bound(all(co),a[i])-co.begin(); int l=1,r=sz; while(l<r){ int m=(l+r)>>1; if(i-lt.qr(1,1,sz,m,m)>d)l=m+1; else r=m; } int tmp = qr1(l-1,id-1,sz)+1;ans=max(ans,tmp); if(l<=id)upd2(id-1,tmp,sz); else upd1(id-1,tmp,sz); lt.upd(1,1,sz,id,sz,i); }cout<<ans; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:68:53: error: no matching function for call to 'max(long long int&, int&)'
   68 |         int tmp = qr1(l-1,id-1,sz)+1;ans=max(ans,tmp);
      |                                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:68:53: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   68 |         int tmp = qr1(l-1,id-1,sz)+1;ans=max(ans,tmp);
      |                                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:68:53: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   68 |         int tmp = qr1(l-1,id-1,sz)+1;ans=max(ans,tmp);
      |                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Main.cpp:68:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   68 |         int tmp = qr1(l-1,id-1,sz)+1;ans=max(ans,tmp);
      |                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Main.cpp:68:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   68 |         int tmp = qr1(l-1,id-1,sz)+1;ans=max(ans,tmp);
      |                                                     ^