2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018) I. Inflation Solution

  Solution in C++:

///**********ALLAH IS ALMIGHTY************///

///AH Tonmoy

///Department of CSE,23rd batch

///Islamic University,Bangladesh  

#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n,i,f=0,k=0;

    cin>>n;

    double a[n+5],b[n+3],v;

    for(i=0; i<n; i++)

    {

        cin>>b[i];

        k++;

        a[i]=k;

    }

    sort(b,b+n);

    v=(b[0]/a[0]);

    for(i=0; i<n; i++)

    {

        if(a[i]<b[i])

        {

            f=1;

            break;

        }

        else

        {

            v=min(v,(b[i]/a[i]));

        }

    }

    if(a[n-1]<b[n-1])

        f=1;

    if(f==1)

        cout<<"-1"<<endl;

    else

        cout<<v<<endl;


}

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.