제출 #1333437

#제출 시각아이디문제언어결과실행 시간메모리
1333437miniobSure Bet (CEOI17_sure)C++20
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
using namespace std;

int main() 
{
	int n;
	cin >> n;
	vector<double> a;
	vector<double> b;
	for(int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	double odp = 0;
	double suma1 = 0;
	double suma2 = 0;
	int it = 0;
	for(int i = 0; i < n; i++)
	{
		suma1 += a[i];
		while(it < n && min(suma1, suma2) - (double)i - (double)1 - (double)it < min(suma1, suma2 + b[it]) - (double)i - (double)1 - (double)it - (double)1)
		{
			suma2 += b[it];
			it++;
		}
		odp = max(odp, min(suma1, suma2) - (double)i - (double)1 - (double)it);
	}
	cout << odp << endl;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...