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

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.