996B Codeforces - World Cup




Solution in c++


#include <bits/stdc++.h>

using namespace std;

int main()

{

    long long int n,mysol=0,sol_stp=10000000000000000,sol=0;
    cin>>n;

    long double b;
    for(int i=0;i<n;i++){
        cin>>b;

       if((floor(b/n*1.0))*n+i>=b){mysol=floor(b/n*1.0)*n+i;}
        else{
            mysol=ceil(b/n*1.0)*n+i;
        }

        if(b<n && i>=b){
            mysol=i;
        }
        else if(b<n && i!=b){

            mysol=n+i;
        }
        if(mysol<sol_stp){sol=i+1;sol_stp=mysol;}

    }
    cout<<sol<<"\n";
    return 0;

}
Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق