제출 #118276

#제출 시각아이디문제언어결과실행 시간메모리
118276teomrnSure Bet (CEOI17_sure)C++14
100 / 100
123 ms3740 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;

	vector <double> v1(n), v2(n);

	for (int i = 0; i < n; i++)
		cin >> v1[i] >> v2[i];

	sort(v1.rbegin(), v1.rend());

	sort(v2.rbegin(), v2.rend());

	for (int i = 1; i < n; i++)
		v1[i] += v1[i - 1], v2[i] += v2[i - 1];

	auto solve = [](vector <double>& v, vector <double>& oth) -> double {
		double best = 0;

		for (int i = 0; i < v.size(); i++) {
			/// iau prefixul de lungime i din v
			int loc = lower_bound(oth.begin(), oth.end(), v[i]) - oth.begin();
			if (loc != oth.size())
				best = max(best, min(v[i], oth[loc]) - i - loc - 2);
			if (loc != 0)
				best = max(best, min(v[i], oth[loc - 1]) - i - loc - 1);
		}
		return best;
	};

	double ans = max(solve(v1, v2), solve(v2, v1));

	cout << setprecision(4) << fixed << ans << '\n';

	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sure.cpp: In lambda function:
sure.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++) {
                   ~~^~~~~~~~~~
sure.cpp:29:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (loc != oth.size())
        ~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...