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

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.