Tag: problem: (B) Urbanization Solution in C/C++

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; int main() { int n,n1,n2; scanf("%d%d%d",&n,&n1,&n2); for(int i=0;i<n;i++) scanf("%d",&w); qsort(w,n,sizeof(w),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; } for(int i=n1;i<n1+n2;i++) { count2+=1.0*w; } printf("%.8lfn",count1/n1+count2/n2); return 0; }

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!