QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#593717#9123. Kth SumFAKUMARERCompile Error//C++233.1kb2024-09-27 15:38:142024-09-27 15:38:14

Judging History

你现在查看的是最新测评结果

  • [2024-09-27 15:38:14]
  • 评测
  • [2024-09-27 15:38:14]
  • 提交

answer

# include <bits/stdc++.h>

const int32_t maxn = 100005;

const int64_t inf  = 3e9;

int64_t n, k, s;

int64_t a[maxn], b[maxn], c[maxn];

std::vector <int32_t> used;

inline int64_t rnk (const int64_t val, const int64_t lim) {
	int64_t rk = 0, pos = 0;

	if (!used.empty ()) return std::lower_bound (used.begin (), used.end (), val) - used.begin ();

	if (val < 0) return 0;
	if (val > a[std::min (lim / n + 1, n)] + b[n]) return n * n;
	if (val > a[n] + b[std::min (lim / n + 1, n)]) return std::cerr << val << '\n', n * n;

	pos = std::lower_bound (a + 1, a + n + 1, val - b[1]) - a - 1;

	for (int i = 1; i <= n; ++ i) {
		while (pos > 0 && a[pos] >= val - b[i]) -- pos;
		rk += pos;
	}
	
	return rk;
}



inline int64_t check (const int64_t val) {
	
	int64_t rk = 0;
	
	for (int i = 1; i <= n; ++ i) {
		rk += rnk (val - c[i], k - rk);
		if (rk >= k) return rk;
	}
	
	return rk;
}


inline void getans (int64_t & ans, const int64_t x) {
	int64_t a = check (x - 2), b = check (x - 1), c = check (x), d = check (x + 1), e = check (x + 2);
	
	std::cerr << a << ' ' << b << ' ' << c << ' '  << d << ' ' << e << ' ' << x << '\n';
	
	if (a <  k && k <= b) return ans = x - 2, void ();
	if (b <  k && k <= c) return ans = x - 1, void ();
	if (c <  k && k <= d) return ans = x, void ();
	if (d <  k && k <= e) return ans = x + 1, void ();
	if (e <  k) return ans = x + 2, void ();
}

inline int64_t getmax () {
	int64_t res = inf;
	for (int i = k / n + 1; i <= n; ++ i)
		res = std::min ({res, a[i] + b[k / i + 1] + c[1], a[i] + c[k / i + 1] + b[1], b[i] + a[k / i + 1] + c[1], b[i] + c[k / i + 1] + a[1], c[i] + a[k / i + 1] + b[1], c[i] + b[k / i + 1] + a[1]});
	return res;
}

int64_t ans = 0;

int main () {
	
//	freopen ("turtle.in", "r", stdin);
//	freopen ("turtle.out", "w", stdout);
	
	std::ios::sync_with_stdio (0);
	std::cin.tie (0), std::cout.tie (0);
	
	std::cin >> n >> k;
	
	for (int i = 1; i <= n; ++ i) std::cin >> a[i];
	
	for (int i = 1; i <= n; ++ i) std::cin >> b[i];
	
	for (int i = 1; i <= n; ++ i) std::cin >> c[i];

	std::sort (a + 1, a + n + 1);
	
	std::sort (b + 1, b + n + 1);
	
	std::sort (c + 1, c + n + 1);
	
//	s = std::sqrt (k / n) + 1;
	
	s = std::min (n, 1000ll);
	
	int64_t l = 0, r = inf, m = 0;
	
	while (l < r) {
		m = (l + r) >> 1;
		if (rnk (m, k) >= std::sqrt (n * k)) r = m;
		else l = m + 1;
	}
	
	if (n * n < 1e7) {
		for (int i = 1; i <= n; ++ i)
			for (int j = 1; j <= n; ++ j)
				used.push_back (a[i] + b[j]);
	} else {
		for (int i = 1; i <= n; ++ i)
			for (int x = 1; a[x] + b[i] < m && x <= n && used.size () <= 1e7; ++ x)
				used.push_back (a[x] + b[i]);
		std::cerr <<  "siz " << used.size () << " lim " << m << '\n';
		for (int i = 1; i <= n; ++ i)
			for (int x = 1; a[x] + b[i] == m && x <= n && used.size () <= 1e7; ++ x)
				used.push_back (a[x] + b[i]);
	}
	
	std::sort (used.begin (), used.end ());
	
//	std::cerr << getmax () << '\n';
	
	l = 0, r = getmax (), m = 0;
	
	while (l < r) {
		m = (l + r) >> 1;
		if (check (m) >= k) r = m - 1;
		else l = m + 1;
	}
	
	getans (ans, m);
	
	std::cout << ans << '\n';
	
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:92:22: error: no matching function for call to ‘min(int64_t&, long long int)’
   92 |         s = std::min (n, 1000ll);
      |             ~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:92:22: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   92 |         s = std::min (n, 1000ll);
      |             ~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:92:22: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   92 |         s = std::min (n, 1000ll);
      |             ~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:92:22: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   92 |         s = std::min (n, 1000ll);
      |             ~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:92:22: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   92 |         s = std::min (n, 1000ll);
      |             ~~~~~~~~~^~~~~~~~~~~