Submission #654183

#TimeUsernameProblemLanguageResultExecution timeMemory
654183Mohammad_ParsaFinancial Report (JOI21_financial)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; //#define int long long #define ll long long #define F first #define S second #define pb push_back const int N=3e5+7; int dp[N],v[N],a[N]; map<int,int> mp; vector<int> vec; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n,d; cin>>n>>d; for(int i=0;i<n;i++){ cin>>a[i];vec.pb(a[i]); } sort(vec.begin(),vec.end()); vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end()))); for(int i=0;i<vec.size();i++){ v[i]=vec[i]; mp[vec[i]]=i; } int ans=1; dp[1]=a[0]; for(int i=1;i<n;i++){ int l=1,r=ans+1; while(r-l>1){ int m=(l+r)/2; if(dp[m]>=a[i]) r=m; else l=m; } dp[l+1]=min(dp[l+1,a[i]); if(l==ans) ans++; } cout<<ans; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
Main.cpp:37:25: warning: left operand of comma operator has no effect [-Wunused-value]
   37 |         dp[l+1]=min(dp[l+1,a[i]);
      |                        ~^~
Main.cpp:37:32: error: expected ']' before ')' token
   37 |         dp[l+1]=min(dp[l+1,a[i]);
      |                                ^
      |                                ]
Main.cpp:37:32: error: no matching function for call to 'min(int&)'
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:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:37:32: note:   candidate expects 2 arguments, 1 provided
   37 |         dp[l+1]=min(dp[l+1,a[i]);
      |                                ^
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:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:37:32: note:   candidate expects 3 arguments, 1 provided
   37 |         dp[l+1]=min(dp[l+1,a[i]);
      |                                ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:37:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |         dp[l+1]=min(dp[l+1,a[i]);
      |                                ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:37:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |         dp[l+1]=min(dp[l+1,a[i]);
      |                                ^