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.

解法:

 #include<stdio.h>
int main(){
int n,i;
int a[];
while(scanf("%d",&n)){
for(i=;i<n;i++)
scanf("%d",&a[i]);
if(n==&&a[n-]!=&&a[n-]!=)
printf("-1\n");
else if(a[n-]==) printf("DOWN\n");
else if(a[n-]==) printf("UP\n");
else if(a[n-]<&&a[n-]<a[n-])
printf("UP\n");
else if(a[n-]<&&a[n-]>a[n-])
printf("DOWN\n");
}
return ;
}

Codeforces 719A 月亮的更多相关文章

  1. codeforces 719A Vitya in the Countryside(序列判断趋势)

    题目链接:http://codeforces.com/problemset/problem/719/A 题目大意: 题目给出了一个序列趋势 0 .1 .2 .3 ---14 .15 .14 ----3 ...

  2. CodeForces 719A Vitya in the Countryside 思维题

    题目大意:月亮从0到15,15下面是0.循环往复.给出n个数字,如果下一个数字大于第n个数字输出UP,小于输出DOWN,无法确定输出-1. 题目思路:给出0则一定是UP,给出15一定是DOWN,给出其 ...

  3. CodeForces 719A. Vitya in the Countryside

    链接:[http://codeforces.com/group/1EzrFFyOc0/contest/719/problem/A] 题意: 给你一个数列(0, 1, 2, 3, 4, 5, 6, 7, ...

  4. codeforces 719A:Vitya in the Countryside

    Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he go ...

  5. CodeForces 719A Vitya in the Countryside (水题)

    题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, & ...

  6. 【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 ...

  7. Codeforces水题集合[14/未完待续]

    Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...

  8. Codeforces Round #373 (Div. 2)A B

    Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 这回做的好差啊,a想不到被hack的数据,b又没有想到正确的思维 = = [题目链 ...

  9. Codeforces 989 P循环节01构造 ABCD连通块构造 思维对云遮月参考系坐标轴转换

    A 直接判存不存在连续的三个包含A,B,C就行 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a ...

随机推荐

  1. APM实践目录

    长路漫漫,如果不能作出一款可用开源的东西出来,那是对时光的浪费.   这是我的学习分布式调用链的实践之路! 思考大纲: .Net架构篇:思考如何设计一款实用的分布式监控系统? 理论篇: http:// ...

  2. 基于ASP.NET 4.0开发的微商城系统OdnShop,开源发布

    基于ASP.NET 4.0开发的开源微商城系统,我们的目标是构建一个核心完善而又轻量级的微商城平台,目前基本的核心功能,包括微信登陆/支付,产品管理,购物车与订单管理等,轻量级是为了更加便于理解源码和 ...

  3. 【React】开发一个城市选择控件

    想到做这个,是因为无意中在github上看到了这一个仓库https://github.com/lunlunshiwo/ChooseCity,做的就是一个城市选择控件,是用vue写的,说的是阿里的一道题 ...

  4. Nice Garland CodeForces - 1108C (思维+暴力)

    You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ...

  5. centos7 安装phpmyadmin

    1.先安装epel,不然安装pgpmyadmin时会出现找不到包. yum install epel-release rpm -ivh http://rpms.famillecollet.com/en ...

  6. 第四章 MyBatis-SQL映射文件

    MyBatis 真正的强大在于映射语句,专注于SQL,功能强大,SQL映射的配置却是相当简单 SQL映射文件的几个顶级元素(按照定义的顺序) mapper - namespace cache - 配置 ...

  7. C99标准的柔性数组 (Flexible Array)

    [什么是柔性数组(Fliexible Array)] 柔性数组在C99中的定义是: 6.7.2.1 Structure and union specifiers As a special case, ...

  8. 获取环境变量,0x000000cb 操作系统找不到已输入的环境选项

    include "stdafx.h" #include <Windows.h> #include <iostream> #pragma warning(di ...

  9. Azure系列2.1.3 —— BlobEncryptionPolicy

    (小弟自学Azure,文中有不正确之处,请路过各位大神指正.) 网上azure的资料较少,尤其是API,全是英文的,中文资料更是少之又少.这次由于公司项目需要使用Azure,所以对Azure的一些学习 ...

  10. 排查 Maxwell can not find database 并且使用 MySQL binlog 解决相关问题

    目前我们在使用 Maxwell 在读线上机器的 binlog 同步我们的离线数据库. 这次错误定位上,首先线要确定问题是发生在生产者 还是队列 还是消费者.经过查看各机器上任务的运行日志,定位到了问题 ...