Submission #99570

# Submission time Handle Problem Language Result Execution time Memory
99570 2019-03-05T10:47:24 Z Mercenary Global Warming (CEOI18_glo) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;
#define taskname "TEST"
#define pb	push_back
#define mp 	make_pair
typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;

int n , x , a[maxn];
int prefix[maxn];

void enter()
{
    cin >> n >> x;
    for(int i = 1 ; i <= n ; ++i)
        cin >> a[i];
}

int b[maxn];

void solve()
{
    int m = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        int k = lower_bound(b + 1 , b + m + 1 , a[i]) - b;
        b[k] = a[i];
        m = max(m , k);
        prefix[i] = k;
    }
    int res = 0;
    m = 0;
    for(int i = n ; i >= 1 ; --i)
    {
        res = max(res , min(m , lower_bound(b + 1 , b + m + 1 , a[i] , greater<int>()) - b - 1) + prefix[i]);
        int k = lower_bound(b + 1 , b + m + 1 , a[i] + x , greater<int>()) - b;
        b[k] = a[i] + x;
        m = max(m , k);
    }
    cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    enter();
    solve();
}

Compilation message

glo.cpp: In function 'void solve()':
glo.cpp:38:95: error: no matching function for call to 'min(int&, long int)'
         res = max(res , min(m , lower_bound(b + 1 , b + m + 1 , a[i] , greater<int>()) - b - 1) + prefix[i]);
                                                                                               ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from glo.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
glo.cpp:38:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
         res = max(res , min(m , lower_bound(b + 1 , b + m + 1 , a[i] , greater<int>()) - b - 1) + prefix[i]);
                                                                                               ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from glo.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
glo.cpp:38:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
         res = max(res , min(m , lower_bound(b + 1 , b + m + 1 , a[i] , greater<int>()) - b - 1) + prefix[i]);
                                                                                               ^
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:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
glo.cpp:38:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         res = max(res , min(m , lower_bound(b + 1 , b + m + 1 , a[i] , greater<int>()) - b - 1) + prefix[i]);
                                                                                               ^
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:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
glo.cpp:38:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         res = max(res , min(m , lower_bound(b + 1 , b + m + 1 , a[i] , greater<int>()) - b - 1) + prefix[i]);
                                                                                               ^
glo.cpp: In function 'int main()':
glo.cpp:51:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(taskname".INP", "r",stdin) ,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
         freopen(taskname".OUT", "w",stdout);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
glo.cpp:51:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]