Submission #149148

# Submission time Handle Problem Language Result Execution time Memory
149148 2019-09-01T05:49:57 Z bitKOIn(#3612, gs15120, phsongys) Crosses on the Grid (FXCUP4_cross) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>

int st[524288];

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int N = I.size();
	int NN = 1;
	for (int t = N - 1; t; t >>= 1) NN <<= 1;
	std::vector<std::pair<int, int>> T;
	std::vector<int> CC(O);
	T.reserve(N);
	for (int i = 0; i < N; ++i) T.push_back({-I[i], O[i]});
	std::sort(T.begin(), T.end());
	std::sort(CC.begin(), CC.end());
	CC.erase(std::unique(CC.begin(), CC.end()), CC.end());
	long long ans = 0;

	for (int i = 0; i < N; ++i) {
		int ii = std::lower_bound(CC.begin(), CC.end(), T[i].second) - CC.begin();
		++st[NN + ii];
		for (int p = NN + ii; (p >>= 1); ) st[p] = st[p << 1] + st[p << 1 | 1];
		if (i >= K - 1) {
			int rem = i - K + 1;
			int p = 1;
			for (; p < NN; )
			{
				if (st[p << 1] <= rem) rem -= st[p], p = p << 1 | 1;
				else p <<= 1;
			}
			if (st[p] <= rem) ++p;
			long long ov = CC[p - NN];
			long long dv = std::max(0, ov + T[i].first);
			// fprintf(stderr, "%d %d %d %lld %lld\n", i, p, -T[i].first, ov, dv);
			ans = std::max(ans, ov * ov - dv * dv);
		}
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:35:46: error: no matching function for call to 'max(int, long long int)'
    long long dv = std::max(0, ov + T[i].first);
                                              ^
In file included from /usr/include/c++/7/vector:60:0,
                 from cross.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:
cross.cpp:35:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    long long dv = std::max(0, ov + T[i].first);
                                              ^
In file included from /usr/include/c++/7/vector:60:0,
                 from cross.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:
cross.cpp:35:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    long long dv = std::max(0, ov + T[i].first);
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from cross.cpp:2:
/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:
cross.cpp:35:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    long long dv = std::max(0, ov + T[i].first);
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from cross.cpp:2:
/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:
cross.cpp:35:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    long long dv = std::max(0, ov + T[i].first);
                                              ^