Codeforces 200B. Drinks Solution

Solve in c++:

#include<bits/stdc++.h>
using namespace std;
int main()
{

    double n,s=0,mx=0,v,t,f;
    int ar[101],i,j,c;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>ar[i];
        mx=ar[0];
        for(j=0; j<n; j++)
        {
            if(ar[j]>mx)
            {
                mx=ar[j];
            }
        }

    }

    for(c=0; c<n; c++)
    {
        if(mx==0)
        {
            f=1;
        }
        else
        {
            f=2;
            v=ar[c]/mx;
            s=s+v;
        }


    }
    if(f==1)
        printf("0.000000000000\n");
    else
    {
     t=(s*mx)/n;
    printf("%.12lf\n",t);
    }

    t=0;

}




No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.