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, & ...
随机推荐
- c++11 类默认函数的控制:"=default" 和 "=delete"函数 void fun() = default; void fun()=delete;
转自:lsgxeva #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #includ ...
- forEach方法的实现
var arr = [1, 23, 1, 1, 1, 3, 23, 5, 6, 7, 9, 9, 8, 5]; Array.prototype.forEach = Array.prototype.fo ...
- VS2010/MFC编程入门之八(对话框:创建对话框类和添加控件变量)
前两讲中鸡啄米为大家讲解了如何创建对话框资源.创建好对话框资源后要做的就是生成对话框类了.鸡啄米再声明下,生成对话框类主要包括新建对话框类.添加控件变量和控件的消息处理函数等. 因为鸡啄米给大家的例程 ...
- uva1423 巧用拓扑排序
对于一个序列 a1 a2 ... an 我们可以计算出一个符号矩阵A, 其中Si,j 为 a1+...+aj 的正负号,(连加和大于0则Sij=+ 小于0 Sij=- 等于0 则Sij=0), 根据 ...
- Linux查看网卡UUID另一方法
转自:http://liaoronghui.com/linux-view-network-adapter-uuid-other-law.html 有时我们不小心将/etc/sysconfig/netw ...
- Vue学习笔记之Vue指令系统介绍
所谓指令系统,大家可以联想咱们的cmd命令行工具,只要我输入一条正确的指令,系统就开始干活了. 在vue中,指令系统,设置一些命令之后,来操作我们的数据属性,并展示到我们的DOM上. OK,接下来我们 ...
- personal evolution
自我清醒 认知自我的行为和心理 你确定你自己是出于理智而发出某种行为? 首先需要确定哪些是人的天性 认知失调理论 从众效应 晕轮效应 霍桑效应 马太效应 期望效应 刻板效应 破窗效应 安排思维 安排闲 ...
- P4行为模型BMV2安装
前提:依赖关系请移步上篇博客.P4行为模型BMV2依赖关系安装:thrift nanomsg nnpy安装 以及,要把下面这些东西装好. On Ubuntu 14.04, the following ...
- css3 导入字体
在CSS中导入字体或是字体ICON @font-face{ src: url("具体的字体地址"), url("具体的字体地址"); }
- redis事务和脚本
事务,简单理解就是,一组动作,要么全部执行,要么就全部不执行.从而避免出现数据不一致的情况. redis提供了简单的事务功能,将一组需要的命令放到multi和exec两个命令之间.multi代表事务开 ...