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. 8.Python初窥门径(文件操作)

    Python (文件操作) 一.文件操作方式 打开文件 open 操作文件 read or write 关闭文件 close 二.打开文件的方式(第一种) 语法 : f=open("文件&q ...

  2. LCS最大公共子序列【转载】

    在两个字符串中,有些字符会一样,可以形成的子序列也有可能相等,因此,长度最长的相等子序列便是两者间的最长公共字序列,其长度可以使用动态规划来求. 以s1={1,3,4,5,6,7,7,8},s2={3 ...

  3. JDK 简介

    JDK简介 JDK java开发工具包 JRE java 运行时环境 JVM java虚拟机 三者的关系:JDK 包含 JRE,JRE 包含 JVM Java的核心优势是跨平台,由JVM虚拟机实现的. ...

  4. XHR的跨域请求和JSONP详解

    首先:什么是跨域? Cross Domain Request:从一个资源请求另一个资源,二者所在的请求地址不同,域名不同.端口号不同.请求协议不同. 它是由浏览器的同源策略造成的,是浏览器对JavaS ...

  5. 题解 BZOJ 1912 && luogu P3629 [APIO2010]巡逻 (树的直径)

    本来抄了篇题解,后来觉得题解都太不友好(我太菜了),一气之下自己打...一打打到第二天QAQ 首先什么边也不加时,总路程就是2*(n-1) 考虑k=1的时候,答案显然是2*(n-1)-直径+1=2*n ...

  6. HDU6442(二项式)

    要点 懒得打公式了,题解 把题目要求的复杂公式化简成熟悉的东西,一是看穿前面加个\(n!\)化为\(C_n^i,i为奇数\):二是将奇数的条件去掉的数学技巧. 形为\({(a + b\sqrt{B}) ...

  7. 线程池(2)Executors.newFixedThreadPool

    例子: ExecutorService es = Executors.newFixedThreadPool(5); try { for (int i = 0; i < 20; i++) { Ru ...

  8. jQuery banner切换插件

    今天学写了一个基于jQuery焦点图切换插件,有不对的地方还请多多指教,不多说下面是代码: 1.引jQuery库 <script src="http://code.jquery.com ...

  9. 一道笔试题和UML思想 ~

    一句软件工程界的名言,让我想起了一个和一道笔试题有关的故事.希望更多的人了解 UML 背后的思想比他的语法更重要,是笔者写作本文的一点小愿望. 一.从一句软件工程名言说起 对很多事情的处理上,东西方都 ...

  10. sql 2008 中不能创建数据库关系图

    执行以下命令: ALTER AUTHORIZATION ON DATABASE::[databasename] TO sa [databasename] 为数据库名: 此方法借鉴于<老高> ...