Codefores A. Vitya in the Countryside

//Next Codeforces Round #354 (Div. 2)
#include<bits/stdc++.h>

//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>

using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;

int ar[100];

int main()
{
    fast;
    int n ,  i;
    while(cin >> n)
    {
        if(n == 1)
        {
            cin >> ar[0];

            if(ar[0] == 15) outn("DOWN");
            else if(ar[0] == 0) outn("UP");
            else outn("-1");
            continue;
        }

        for(i=0; i<n; i++)
        {
            cin >> ar[i];
        }

        if(ar[n-1] > ar[n-2])
        {
            if(ar[n-1] == 15) outn("DOWN");
            else if(ar[n-1] == 0) outn("UP");
            else outn("UP");
        }

        else
        {
            if(ar[n-1] == 15) outn("DOWN");
            else if(ar[n-1] == 0) outn("UP");
            else outn("DOWN");
        }
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number