Submission #1007681

#TimeUsernameProblemLanguageResultExecution timeMemory
1007681devariaotaGlobal Warming (CEOI18_glo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i=a; i<=(b); i++) #define F0R(i, a) for (int i=0; i<(a); i++) #define FORd(i,a,b) for (int i = (b); i >= a; i--) #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--) #define trav(a,x) for (auto& a : x) #define int long long #define ld long double #define lb lower_bound #define ceil(a,b) (a+(b-1))/b #define ins insert #define ub upper_bound #define pb push_back #define VI vector<int> #define VVI vector<VI> #define PII pair<int,int> #define VII vector<PII> #define size(x) x.size() #define all(x) x.begin(), x.end() #define fi first #define se second const int mod = 1e9+7; const int N = 2e5 + 5; // const int mod = 998244353; int binser(vector<int>&temp,int num){ int l =0,r=size(temp)-1,ind,mid; while(l<=r){ mid=(l+r)/2; if(num>=temp[mid]){ ind=mid; r=mid-1; } else{ l=mid+1; } } // if(num>=temp[ind]){ return ind; // } // else return -1; } void solve(){ int n,k; cin>>n>>k; int arr[n]; for(int i =0 ;i<n;i++){ cin>>arr[i]; } int inc[n],linc[n]; inc[0]=arr[0]; linc[0]=1; vector<int> temp; int ans=0; temp.push_back(arr[0]); for (int i = 1; i < n; i++) { if (arr[i] > temp.back()) { temp.push_back(arr[i]); } else { int ind = lower_bound(temp.begin(), temp.end(), arr[i]) - temp.begin(); temp[ind] = arr[i]; } inc[i]=temp.back(); linc[i]=size(temp); } // for(int i =0;i<n;i++){ // cout<<inc[i]<<" "<<linc[i]<<endl; // } // trav(it,temp){ // cout<<it<<" "; // } ans=size(temp); temp.clear(); temp.push_back(arr[n-1]); for (int i = n-2; i >= 0; i--) { // trav(it,temp){ // cout<<it<<" "; // } // cout<<endl; ans=max(ans,linc[i]+(size(temp)-binser(temp,inc[i]-k+1))); if (arr[i] < temp.back()) { temp.push_back(arr[i]); } else { int ind=binser(temp,arr[i]); temp[ind] = arr[i]; } } cout<<ans<<endl; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int t=1; cout<<setprecision(12)<<fixed; // cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

glo.cpp: In function 'void solve()':
glo.cpp:81:65: error: no matching function for call to 'max(long long int&, long long unsigned int)'
   81 |         ans=max(ans,linc[i]+(size(temp)-binser(temp,inc[i]-k+1)));
      |                                                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from glo.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:
glo.cpp:81:65: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   81 |         ans=max(ans,linc[i]+(size(temp)-binser(temp,inc[i]-k+1)));
      |                                                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from glo.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:
glo.cpp:81:65: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   81 |         ans=max(ans,linc[i]+(size(temp)-binser(temp,inc[i]-k+1)));
      |                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from glo.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:
glo.cpp:81:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   81 |         ans=max(ans,linc[i]+(size(temp)-binser(temp,inc[i]-k+1)));
      |                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from glo.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:
glo.cpp:81:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   81 |         ans=max(ans,linc[i]+(size(temp)-binser(temp,inc[i]-k+1)));
      |                                                                 ^