Submission #1288307

#TimeUsernameProblemLanguageResultExecution timeMemory
1288307tunademayoLet's Win the Election (JOI22_ho_t3)C++20
10 / 100
9 ms492 KiB
#include<bits/stdc++.h>
using namespace std;

#define ll long long 
#define ld long double

const bool Multitest = 0;

const int N = 505; const ll offset = 1e9;

int n, k;

struct Type 
{
	ld x, y;
}; Type a[N];

bool cmp1(Type a, Type b)
{
	return a.y < b.y;
}

bool cmp2(Type a, Type b)
{
	return a.x < b.x;
}

void work()
{
	cin >> n >> k;
	
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> a[i].x >> a[i].y;
		if(a[i].y == -1) a[i].y = 1e9;
	}
	
	sort(a + 1, a + 1 + n, cmp1);
	
	ld ans = 1e18, t = 0;
		
	for(int i = 0 ; i <= k ; i++)
	{
		if(i != 0)
		{
			t += a[i].y / i;
		}
		vector<Type> b;
		
		for(int j = i + 1 ; j <= n ; j++) b.push_back(a[j]);
		
		sort(b.begin(), b.end(), cmp2);
		
//		for(auto x : b)
//		{
//			cout << x.x << ' ' << x.y << '\n';
//		}
		
		ld at = 0;
		
		for(int x = 0 ; i + x < k ; x++)
		{
			at += b[x].x / (i + 1);
		}
		
		ans = min(ans, t + at);
	}
	
	cout << setprecision(9) << fixed << (1.0 * ans); 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	cout.tie(0);

	int q = 1;
	
	if(Multitest)	cin >> q;
	
	while(q--) work();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...