Submission #133847

#TimeUsernameProblemLanguageResultExecution timeMemory
133847miguelGlobal Warming (CEOI18_glo)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define rc(x) return cout<<x<<endl,0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define int ll #define sz size() #define x first #define y second #define pi pair <int, int> #define pii pair <pi, pi> #define vi vector <int> const ll nmax=5e4+2; const ll mod = 998244353; int n, x, s[200001], a[200001]; vector <int> dp; int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>n>>x; //dp.pb(0); for(int i=1; i<=n; i++){ cin>>a[i]; auto it=lower_bound(dp.begin(), dp.end(), a[i]); if(it==dp.end()){ dp.pb(a[i]); s[i]=dp.size(); } else{ dp[it-dp.begin()]=a[i]; s[i]=it-dp.begin()+1; } } // for(int i: dp) cout<<i<<" "; cout<<endl; //for(int i=1; i<=n; i++) cout<<s[i]<<" "; int ans=dp.size(); vi lsd; for(int i=n; i>=1; --i){ auto it=lower_bound(lsd.begin(), lsd.end(), -a[i]); if(it==lsd.end()) ans=max(ans, s[i]+lsd.size()); else ans=max(ans, s[i]+(it-lsd.begin())); auto it1=lower_bound(lsd.begin(), lsd.end(), -a[i]-x); if(it1==lsd.end()) lsd.pb(-a[i]-x); else lsd[it1-lsd.begin()]=-a[i]-x; } cout<<ans; }

Compilation message (stderr)

glo.cpp: In function 'int32_t main()':
glo.cpp:42:55: error: no matching function for call to 'max(long long int&, long long unsigned int)'
         if(it==lsd.end()) ans=max(ans, s[i]+lsd.size());
                                                       ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from glo.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
glo.cpp:42:55: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
         if(it==lsd.end()) ans=max(ans, s[i]+lsd.size());
                                                       ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from glo.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
glo.cpp:42:55: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
         if(it==lsd.end()) ans=max(ans, s[i]+lsd.size());
                                                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from glo.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
glo.cpp:42:55: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         if(it==lsd.end()) ans=max(ans, s[i]+lsd.size());
                                                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from glo.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
glo.cpp:42:55: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         if(it==lsd.end()) ans=max(ans, s[i]+lsd.size());
                                                       ^