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. js函数-构成

    前言 函数是一种封装,在任何语言中都是一个核心概念.在js中,函数是做为对象的子类型存在的.可以拥有自己的属性和方法,可以做为值进行传递,这两个特性让js拥有使用函数式编程的能力. 函数的声明 字面量 ...

  2. LeetCode 刷题笔记 (树)

    1.  minimum-depth-of-binary-tree 题目描述 Given a binary tree, find its minimum depth.The minimum depth ...

  3. 黑马学习Ajax 跨域资源共享 jQuery+jsonp实现

  4. [TCP/IP]ARP与RARP的总结

    一. 总述 简单的说,ARP协议就是将IP地址转换为MAC物理地址:而RARP,就是ARP的逆向,也就是将MAC物理地址转换为IP地址.看起来这两个协议是完全对称的,但发明这两个协议的初衷基本上没有什 ...

  5. 050 Pow(x, n)

    实现 pow(x, n).示例 1:输入: 2.00000, 10输出: 1024.00000示例 2:输入: 2.10000, 3输出: 9.26100详见:https://leetcode.com ...

  6. Hart协议

    官方https://fieldcommgroup.org/technologies/hart/documents-and-downloads-hart 参考网页http://www.eeworld.c ...

  7. Vue部分知识

    一.本尊建议的学习顺序:https://zhuanlan.zhihu.com/p/23134551(侵删) 二.安装: 1.安装 Node.js,可以去Node.js的官网上下载: 2.(非必选)如果 ...

  8. 13.JAVA-包package、import使用

    1.包的定义 之前我们学习java时,生成的class文件都是位于当前目录中,假如出现了同名文件,则会出现文件覆盖问题,因此就需要设置不同的目录(定义包),来解决同名文件冲突问题. 并且在大型项目中, ...

  9. Eclipse 主题(Theme)配置

    < 程序员大牛必备的装逼神器 > 一个牛逼的程序员,除了有牛逼的技术,还要有高逼格的风格,说白了,就和人一样,单是内在美还不行,必须外表也要美,就好比,一个乞丐,他内在美,但是全身臭气熏天 ...

  10. To the world you may be one person, but to one person you may be the world.

    To the world you may be one person, but to one person you may be the world.对于世界而言,你是一个人:但对于某人而言,你是他的 ...