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, & ...
随机推荐
- Spring MVC同一方法返回JSON/XML格式
最近一道面试题,要求同一API接口支持不同格式返回值.一开始是设想通过过滤器(Filter)设置返回值,但是并不可行,因为方法返回值一般都是类型需要做转换,而过滤器则是前置的.另一方面可以通过拦截器的 ...
- INNODB索引与算法
在之前的博文中简单提到了索引的分类与索引的可选择性查看:Click HERE 这片博客主要包含内容:索引组织表,索引算法B+树简单介绍 索引组织表 在innodb存储引擎中,表都是根据主键顺序组织存放 ...
- Linux内核分析06
进程的描述和进程的创建 一,进程的描述 进程控制块PCB——task_struct (进程描述符),为了管理进程,内核必须对每个进程进行清晰的描述,进程描述符提供了内核所需了解的进程信息. struc ...
- STRIDE 和 DREAD
目录 STRIDE 和 DREAD 背景 STRIDE DREAD 注释 STRIDE 和 DREAD 背景 STRIDE 和 DREAD 是最常用也是最好用的安全模型 STRIDE 主要负责对安全风 ...
- #include <ntifs.h>出现PEPROCESS redefinition问题处理
转载:http://blog.csdn.net/ytfrdfiw/article/details/23334297 如果在自己的程序中,即包含ntddk.h和ntifs.h的时候,编译的时候会出现如下 ...
- 【eclipse】运行maven项目clean tomcat7:run报错
问题: Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean 解决: 关闭进程javaw.exe,然 ...
- IDEA 搭建授权服务器
引用地址 http://blog.lanyus.com/archives/317.html 今天突出发现基本公开的激活地址都被屏蔽了(IDEA 2017.3 版本) 记录一下 docker pull ...
- ZOJ 3769 Diablo III(分组背包)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3769 题意:有13种装备,每种装备值可以穿戴一种,特殊的就是双手武器和单手 ...
- 使用IDEA创建基于Gradle构建的JavaWeb项目
环境配置 jdk: 1.8 Gradle: 4.4.1 Tomcat: 9.0.0 One Step! 创建项目,初始化项目结构. 打开我们的IDEA,进入创建项目的界面,勾选Java,Web两个选项 ...
- 下载百度网盘破解 获得 所下载视频URL 粘贴到thunder
Chrome:方法1. 进入谷歌商城,搜索baidudl.安装即可. 方法2. 下载baidudl.zip.解压获得baidudl文件夹.进入chrome://extensions/,勾选右上角Dev ...