A. Vitya in the Countryside
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down.

Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units) for each day is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, and then cycle repeats, thus after the second 1 again goes 0.

As there is no internet in the countryside, Vitya has been watching the moon for n consecutive days and for each of these days he wrote down the size of the visible part of the moon. Help him find out whether the moon will be up or down next day, or this cannot be determined by the data he has.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 92) — the number of consecutive days Vitya was watching the size of the visible part of the moon.

The second line contains n integers ai (0 ≤ ai ≤ 15) — Vitya's records.

It's guaranteed that the input data is consistent.

Output

If Vitya can be sure that the size of visible part of the moon on day n + 1 will be less than the size of the visible part on day n, then print "DOWN" at the only line of the output. If he might be sure that the size of the visible part will increase, then print "UP". If it's impossible to determine what exactly will happen with the moon, print -1.

Examples
Input
5

3 4 5 6 7
Output
UP
Input
7

12 13 14 15 14 13 12
Output
DOWN
Input
1

8
Output
-1
Note

In the first sample, the size of the moon on the next day will be equal to 8, thus the answer is "UP".

In the second sample, the size of the moon on the next day will be 11, thus the answer is "DOWN".

In the third sample, there is no way to determine whether the size of the moon on the next day will be 7 or 9, thus the answer is -1.

题目链接:http://codeforces.com/problemset/problem/719/A

分析:当时这题还懵了一阵子,之前好像比赛写过,之前直接去取最后两项去比较,WA...心酸!后来看了下题目才发现,得看到临界点0,15,发现这题目很简单!直接做就是了!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
int a[];
while(cin>>n)
{
for(i=;i<=n;i++)
cin>>a[i];
if(n==&&a[n]!=&&a[n]!=)
cout<<-<<endl;
else if(a[n]==)
cout<<"DOWN"<<endl;
else if(a[n]==)
cout<<"UP"<<endl;
else if(a[n]<&&a[n]>a[n-])
cout<<"UP"<<endl;
else if(a[n]<&&a[n]<a[n-])
cout<<"DOWN"<<endl;
}
return ;
}

Code forces 719A Vitya in the Countryside的更多相关文章

  1. codeforces 719A Vitya in the Countryside(序列判断趋势)

    题目链接:http://codeforces.com/problemset/problem/719/A 题目大意: 题目给出了一个序列趋势 0 .1 .2 .3 ---14 .15 .14 ----3 ...

  2. CodeForces 719A Vitya in the Countryside 思维题

    题目大意:月亮从0到15,15下面是0.循环往复.给出n个数字,如果下一个数字大于第n个数字输出UP,小于输出DOWN,无法确定输出-1. 题目思路:给出0则一定是UP,给出15一定是DOWN,给出其 ...

  3. CodeForces 719A. Vitya in the Countryside

    链接:[http://codeforces.com/group/1EzrFFyOc0/contest/719/problem/A] 题意: 给你一个数列(0, 1, 2, 3, 4, 5, 6, 7, ...

  4. CodeForces 719A Vitya in the Countryside (水题)

    题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, & ...

  5. Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 水题

    A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...

  6. 思维题--code forces round# 551 div.2

    思维题--code forces round# 551 div.2 题目 D. Serval and Rooted Tree time limit per test 2 seconds memory ...

  7. A. Vitya in the Countryside

    A. Vitya in the Countryside time limit per test 1 second memory limit per test 256 megabytes input s ...

  8. Code Forces 796C Bank Hacking(贪心)

    Code Forces 796C Bank Hacking 题目大意 给一棵树,有\(n\)个点,\(n-1\)条边,现在让你决策出一个点作为起点,去掉这个点,然后这个点连接的所有点权值+=1,然后再 ...

  9. Code Forces 833 A The Meaningless Game(思维,数学)

    Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...

随机推荐

  1. [Unity c#]c#中的反射

    什么是反射 在.NET中的反射也可以实现从对象的外部来了解对象(或程序集)内部结构的功能,哪怕你不知道这个对象(或程序集)是个什么东西,另外.NET中的反射还可以运态创建出对象并执行它其中的方法. 反 ...

  2. RSA----实际函数库选择

    需求:对字符串加密 加密后不要超过这个字符串的长度,最好是1半的长度. 非对称算法. 重复度一定要低 1使用RSA加密 1   rsaeuro 2openssl    参考openssl编程 3 Cr ...

  3. Keil MDK下如何设置非零初始化变量(转)

    源:Keil MDK下如何设置非零初始化变量 一些工控产品,当系统复位后(非上电复位),可能要求保持住复位前RAM中的数据,用来快速恢复现场,或者不至于因瞬间复位而重启现场设备.而keil mdk在默 ...

  4. jquery在调试时出现缺少对象的错误

    1)引入的js文件出错,  检查方法:将Js的内容写在当前的页面的<script> </script>之间,看是否能够正常运行,如果不能,请核查代码  2) 如果引入的代码在当 ...

  5. 位图文件(BMP)格式以及Linux下C程序实现(转)

    源:位图文件(BMP)格式以及Linux下C程序实现 说到图片,位图(Bitmap)当然是最简单的,它是Windows显示图片的基本格式,其文件扩展名为*.BMP.由于没有经过任何的压缩,故BMP图 ...

  6. iOS开发——MD5加密

    #import <CommonCrypto/CommonDigest.h> - (NSString *)md5:(NSString *)str { const char *cStr = [ ...

  7. Spring3.2新注解@ControllerAdvice

    Spring3.2新注解@ControllerAdvice   @ControllerAdvice,是spring3.2提供的新注解,从名字上可以看出大体意思是控制器增强.让我们先看看@Control ...

  8. 查看Linux最近重启的时间

    最近实验室老是掉电,想查看服务器什么时候重启的,于是在网上找了一些资料.有两种方式可以查看服务器重启. (1) who -b (2) last reboot |head -1

  9. 可持久化Trie树初步

    可持久化Trie树和可持久化线段树很像,依次插入信息,通过减法来进行历史版本查询. 2015年11月27日 bzoj3261 最大异或和 我们需要计算 a[p] xor a[p+1] xor ... ...

  10. Java程序员常犯的10个错误

      本文总结了Java程序员常犯的10个错误. #1. 把Array转化成ArrayList 把Array转化成ArrayList,程序员经常用以下方法: List<String> lis ...