Codeforces Round #382 (Div. 2), problem: (B) Urbanization Solution in C/C++

#include<stdio.h>
#include<stdlib.h>
int cmp(const void*a,const void*b)
{
return *(int*)b-*(int*)a;
}
int w[100005];
int main()
{
	int n,n1,n2;
	scanf("%d%d%d",&n,&n1,&n2);
	for(int i=0;i<n;i++)
	scanf("%d",&w[i]);
	qsort(w,n,sizeof(w[0]),cmp);
	if(n1>n2)
	{
		int t=n1;
		n1=n2;
		n2=t;
	}
	double count1=0,count2=0;
	for(int i=0;i<n1;i++) 
	{
		count1+=1.0*w[i];
	}
	for(int i=n1;i<n1+n2;i++)
	{
		count2+=1.0*w[i];
	}
	printf("%.8lf\n",count1/n1+count2/n2);
	return 0;
}

Advertisement

spot_img

US and rivals spar...

According to a report by Al Jazeera, diplomatic tensions...

Why Viral Kitchen Gadgets...

📢 As an Amazon Associate, I earn from qualifying...

Curt Cignetti has built...

College football is often dictated by resources, prestige, and...

I Tried Viral Kitchen...

📢 As an Amazon Associate, I earn from qualifying...

Top House Budget Dem...

In response to growing scrutiny over the reliability and...

I Tried Viral Kitchen...

📢 As an Amazon Associate, I earn from qualifying...

US and rivals spar over next UN boss as race lurches towards deadline

According to a report by Al Jazeera, diplomatic tensions among global powers have intensified as the United Nations nears the deadline to select its...

Why Viral Kitchen Gadgets Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Curt Cignetti has built what Lincoln Riley can’t at USC: a team that knows how to win

College football is often dictated by resources, prestige, and five-star recruiting classes. Yet, the stark contrast between Curt Cignetti’s Indiana Hoosiers and Lincoln Riley’s...

I Tried Viral Kitchen Gadgets For 30 Days Here Is the Honest Truth

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Top House Budget Dem Boyle: I’d Support ‘Major Appropriation’ for FAA Overhaul

In response to growing scrutiny over the reliability and resilience of national aviation infrastructure, Representative Brendan Boyle (D-PA) has publicly signaled strong support for...

I Tried Viral Kitchen Gadgets For 30 Days Here Is the Honest Truth

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Viral Kitchen Gadgets through a proper 30-day real-world test, I can tell...

‘Feeling good’ – Shams Charania provides Luka Doncic, Austin Reaves injury updates

Basketball fans can breathe a collective sigh of relief following the latest Luka Doncic Austin Reaves injury updates delivered by trusted NBA insider Shams...

The Ultimate Viral Kitchen Gadgets Guide You Didnt Know You Needed

📢 As an Amazon Associate, I earn from qualifying purchases.Most products in this category disappoint within weeks. Cheap materials, vague instructions, and results that...

Connor Hellebuyck goes to Bass Pro Shops opening in NJ — one day after brutal Winnipeg booing

Professional sports can be an emotional rollercoaster, and few understand that reality better this week than Winnipeg Jets star goaltender Connor Hellebuyck. Just twenty-four...