Vitya in the Countryside
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 nconsecutive 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.
Example
5
3 4 5 6 7
UP
7
12 13 14 15 14 13 12
DOWN
1
8
-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.
就是给出一个数列,按照给的三十天样例,看看能不能确定下一天是down还是up
注意0和15这两个中转点。
代码:
#include<bits/stdc++.h>
using namespace std; int main()
{
int n,a[];
int flag;
cin>>n;
for(int i = ; i < n;i ++)
{
cin>>a[i];
if(i && a[i] > a[i - ])flag = ;
else if(i && a[i] < a[i - ])flag = -;
else if(a[i] == )flag = ;
else if(a[i] == )flag = -;
else flag = ;
}
if(flag > )
{
if(a[n - ] == )cout<<"DOWN";
else cout<<"UP";
}
else if(flag < )
{
if(a[n - ] == )cout<<"UP";
else cout<<"DOWN";
}
else cout<<-;
}
Vitya in the Countryside的更多相关文章
- 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 ...
- 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 ...
- A. Vitya in the Countryside
A. Vitya in the Countryside time limit per test 1 second memory limit per test 256 megabytes input s ...
- codeforces 719A:Vitya in the Countryside
Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he go ...
- 【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 ...
- codeforces 719A Vitya in the Countryside(序列判断趋势)
题目链接:http://codeforces.com/problemset/problem/719/A 题目大意: 题目给出了一个序列趋势 0 .1 .2 .3 ---14 .15 .14 ----3 ...
- CodeForces 719A Vitya in the Countryside 思维题
题目大意:月亮从0到15,15下面是0.循环往复.给出n个数字,如果下一个数字大于第n个数字输出UP,小于输出DOWN,无法确定输出-1. 题目思路:给出0则一定是UP,给出15一定是DOWN,给出其 ...
- CodeForces 719A. Vitya in the Countryside
链接:[http://codeforces.com/group/1EzrFFyOc0/contest/719/problem/A] 题意: 给你一个数列(0, 1, 2, 3, 4, 5, 6, 7, ...
- CodeForces 719A Vitya in the Countryside (水题)
题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, & ...
随机推荐
- ubuntu-未信任的应用程序启动器-XX-Net.desktop
在安装启动xxnet时使用sudo命令,该软件打开后提示[未信任的应用程序启动器]如图所示,解决办法简介:(1)更换成root用户(2)更改权限 背景描述 xx-net中的启动程序有权限设置, ...
- 382. Linked List Random Node(蓄水池采样)
1. 问题 给定一个单链表,随机返回一个结点,要求每个结点被选中的概率相等. 2. 思路 在一个给定长度的数组中等概率抽取一个数,可以简单用随机函数random.randint(0, n-1)得到索引 ...
- linux sar命令详解及使用
sar(System Activity Reporter系统活动情况报告)是目前 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告,包括:文件的读写情况.系统调用的使用情 ...
- Sublime Text 3 插件的安装、升级和卸载
Sublime Text 3 插件的安装.升级和卸载 快捷键:ctrl+shift+p打开命令面板,如图: 1,插件安装: 输入:install ,选择“Install package” ,如图: 然 ...
- 20145307陈俊达《网络对抗》Exp3 免杀原理与实践
20145307陈俊达<网络对抗>Exp3 免杀原理与实践 基础问题回答 杀软是如何检测出恶意代码的? 恶意代码中一般会有一段有较明显特征的代码也就是特征码,如果杀毒软件检测到有程序包含的 ...
- 20145325张梓靖 《Java程序设计》第6周学习总结
20145325张梓靖 <Java程序设计>第6周学习总结 教材学习内容总结 串流设计 输入串流(将数据从来源取出),代表对象为java.io.InputStream实例,输出串流(将数据 ...
- Linux下停止没有关闭的远程登陆终端
脚本如下: #!/bin/shTTY_LOG=tty_logTTY_LOG1=tty_log1USER_NAME=`whoami`#echo ${USER_NAME}who|grep ${USER_N ...
- js urlencode
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- python 去除字符串两端的引号
a='"srting"' print(a) b=eval(a) print(b) 输出 "srting" srting
- Spring之核心容器bean
摘要:Spring的核心容器实现了Ioc,其目 的是提供一种无侵入式的框架.在本文中,首先讲解了Spring的基础bean的相关知识,然后介绍了Spring是如何对bean进行管理的. 在Spring ...