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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.