Codeforces Bear and Game

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    while(cin >> n)
    {
        int x , tmp=15, ans=0;
        bool bore=false;

        for(int i=0; i<n; i++)
        {
            cin >> x;

            if(!bore)
            {
                if(x > tmp)
                {
                    bore = true;
                    ans = tmp;
                }
            }

            tmp = x+15;
        }

        if(!ans)
        {
            if(tmp >= 90) ans=90;
            else ans=tmp;
        }

        cout << ans << "\n";
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number