Submission #702017

#TimeUsernameProblemLanguageResultExecution timeMemory
702017ld_minh4354Financial Report (JOI21_financial)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define debug(x) cout<<#x<<": "<<x<<"\n"; struct node { int s,e,m,val; node *l,*r; node(int S,int E) { s=S;e=E;m=(s+e)/2; val=-1; if (s!=e) { l=new node(s,m); r=new node(m+1,e); } } void update(int X,int V) { if (s==e and s==X) val=V; else { if (X<=m) l->update(X,V); else r->update(X,V); val=max(l->val,r->val); } } int query(int S,int E) { if (s==S and e==E) return val; else if (E<=m) return l->query(S,E); else if (S>=m+1) return r->query(S,E); else return max(l->query(S,m),r->query(m+1,E)); } } *root[7005]; signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("input.000","r",stdin); // freopen("output.000","w",stdout); // srand((unsigned)time(NULL)); // rand() int n,d,i,a[7005],dp[7005][7005],ans,j,k,min_dist,c,pre1,pre2[7005]; cin>>n>>d; for (i=1;i<n+1;i++) cin>>a[i]; if (n==1) { cout<<1;return 0; } for (i=1;i<n+1;i++) root[i]=new node(1,n); for (i=1;i<n+1;i++) pre2[i]=-1; if (a[1]<a[2]) dp[2][1]=2;else dp[2][1]=1; if (a[1]>=a[2]) root[1]->update(2,dp[2][1]); else pre2[2]=dp[2][1]; for (i=3;i<n+1;i++) for (j=1;j<i;j++) { c=0;min_dist=0; for (k=j+1;k<i;k++) if (a[k]>a[j]) { c++; min_dist=max(min_dist,c); } else c=0; if (min_dist<d) { pre1=root[j]->query(max(j,i-d), i-1); dp[i][j]=max(1ll,pre1); if (i-j<=d) dp[i][j]=max(dp[i][j], pre2[j]); if (a[i]>a[j]) dp[i][j]++; } else dp[i][j]=-1; if (a[j]>=a[i]) root[j]->update(i,dp[i][j]); //pre1[j]=max(pre1[j], dp[i][j]); else pre2[i]=max(pre2[i], dp[i][j]); } // for (i=2;i<n+1;i++) // { // for (j=1;j<i;j++) cout<<dp[i][j]<<" "; // cout<<"\n"; // } // for (i=1;i<n+1;i++) debug(pre1[i]); // for (i=1;i<n+1;i++) debug(pre2[i]); ans=1; for (j=1;j<n;j++) ans=max(ans,dp[n][j]); cout<<ans; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:85:25: error: no matching function for call to 'max(long long int, int&)'
   85 |    dp[i][j]=max(1ll,pre1);
      |                         ^
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:85:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   85 |    dp[i][j]=max(1ll,pre1);
      |                         ^
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:85:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   85 |    dp[i][j]=max(1ll,pre1);
      |                         ^
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:85:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   85 |    dp[i][j]=max(1ll,pre1);
      |                         ^
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:85:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   85 |    dp[i][j]=max(1ll,pre1);
      |                         ^