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.

一开始没注意只有0或15的情况,被hack了,QAQ

 #include<iostream>
using namespace std; int S[]={, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , };
int n,m;
int A[]; int main()
{
cin>>n;
for(int i=;i<=n;i++)
cin>>A[i];
if(n==)
switch(A[])
{
case :
cout<<"UP";
return ;
case :
cout<<"DOWN";
return ;
default:
cout<<-;
return ;
}
for(int i=;i<=;i++)
if(A[n-]==S[i-]&&A[n]==S[i])
m=i;
if((<=m&&m<=)||(m==))
{
cout<<"UP";
return ;
}
else
if(<=m&&m<=)
{
cout<<"DOWN";
return ;
}
cout<<-;
return ;
}

A. Vitya in the Countryside的更多相关文章

  1. Code forces 719A Vitya in the Countryside

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

  2. 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 ...

  3. codeforces 719A:Vitya in the Countryside

    Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he go ...

  4. Vitya in the Countryside

    Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge war ...

  5. 【32.89%】【codeforces 719A】Vitya in the Countryside

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

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

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

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

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

  8. CodeForces 719A. Vitya in the Countryside

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

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

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

随机推荐

  1. 关于Struts漏洞工具的使用

    最新struts-scan资源: https://www.cesafe.com/3486.html 一,将资源下载后,放入liunx系统中,并且需要具备python2的操作环境 二,打开终端使用如下命 ...

  2. Acwing 98-分形之城

    98. 分形之城   城市的规划在城市建设中是个大问题. 不幸的是,很多城市在开始建设的时候并没有很好的规划,城市规模扩大之后规划不合理的问题就开始显现. 而这座名为 Fractal 的城市设想了这样 ...

  3. Java基础笔记(四)——命名规则、数据类型

    标识符即Java程序中需要自定义的名称,如变量名.方法名.类名.包名.工程名等. 标识符的命名规则: 1.可由字母.数字.下划线(_)和美元符($)组成,不能以数字开头. 2.严格区分大小写. 3.不 ...

  4. day5字典作业详解

    1.day5题目 1.有如下变量(tu是个元祖),请实现要求的功能 tu = ("alex", [11, 22, {"k1": 'v1', "k2&q ...

  5. p标签间距问题

    用<p></p>标签写文本时,控制行与行之间的高度最好用line-height,不要用margin或padding:   因为P标签本身就带有一定的上下间距,且自带的间距在模拟 ...

  6. Codeforces 1167E(思路、数据处理)

    思路 不难想到枚举\(l\),那如何高效求出最小的\(r\)?这样答案加上\(x-r+1\)即可. 如果\(l\)并没在序列里出现--没啥想法:如果\(l\)是序列里的数,我们可以做的事情是记下每个数 ...

  7. NET Core中使用Dapper操作Oracle存储过程

    .NET Core中使用Dapper操作Oracle存储过程最佳实践   为什么说是最佳实践呢?因为在实际开发中踩坑了,而且发现网上大多数文章给出的解决方法都不能很好地解决问题.尤其是在获取类型为Or ...

  8. 剖析js中的数据类型

    首先说一下八种常见的数据类型:五种简单的数据类型和三种复杂数据类型. 简单数据类型 Number:数字类型 String:字符串 Boolean:布尔类型 Undefined:未定义 Null:空 复 ...

  9. python 3 学习字符串和编码

    字符串和编码 阅读: 895464 字符编码 因为计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.最早的计算机在设计时采用8个比特(bit)作为一个字节(byte),所以,一个字 ...

  10. awk单引号处理

    awk中使用单引号,常规字符串,'\''即可,但如果像下面在$4变量用单引号,则还需要加上双引号才行. cat 2.txt | awk '{ print $1, $2, $3, "'\''& ...