Code forces 719A 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 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.
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.
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.
5
3 4 5 6 7
UP
7
12 13 14 15 14 13 12
DOWN
1
8
-1
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.
题目链接:http://codeforces.com/problemset/problem/719/A
分析:当时这题还懵了一阵子,之前好像比赛写过,之前直接去取最后两项去比较,WA...心酸!后来看了下题目才发现,得看到临界点0,15,发现这题目很简单!直接做就是了!
下面给出AC代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
int a[];
while(cin>>n)
{
for(i=;i<=n;i++)
cin>>a[i];
if(n==&&a[n]!=&&a[n]!=)
cout<<-<<endl;
else if(a[n]==)
cout<<"DOWN"<<endl;
else if(a[n]==)
cout<<"UP"<<endl;
else if(a[n]<&&a[n]>a[n-])
cout<<"UP"<<endl;
else if(a[n]<&&a[n]<a[n-])
cout<<"DOWN"<<endl;
}
return ;
}
Code forces 719A Vitya in the Countryside的更多相关文章
- 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, & ...
- 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 ...
- 思维题--code forces round# 551 div.2
思维题--code forces round# 551 div.2 题目 D. Serval and Rooted Tree time limit per test 2 seconds memory ...
- A. Vitya in the Countryside
A. Vitya in the Countryside time limit per test 1 second memory limit per test 256 megabytes input s ...
- Code Forces 796C Bank Hacking(贪心)
Code Forces 796C Bank Hacking 题目大意 给一棵树,有\(n\)个点,\(n-1\)条边,现在让你决策出一个点作为起点,去掉这个点,然后这个点连接的所有点权值+=1,然后再 ...
- Code Forces 833 A The Meaningless Game(思维,数学)
Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...
随机推荐
- AWK第一篇------全面介绍
AWK-文本流编辑器 目录 [隐藏] 1 命令行语法 2 用shell实现调用awk 3 awk语言概要 3.1 记录和字段 3.2 脚本的格式 3.3 行为终止 3.4 注释 3.5 模式 3.6 ...
- Mac下安装包管理平台Homebrew(Mac 10.12)
在终端上输入: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/maste ...
- Android 编译错误
本人使用的是Android studio1.3版本,前几天调试通过的项目,现在编译出现了错误.错误信息如下 Project app: apk dependencies can only be jars ...
- mysql优化------2 查看系统性能(表大小,I/o性能)
三:判断mysql I/0 性能的一种方式(网络搜集供参考) show global status like 'innodb_dblwr%'\G 如果innodb_dblwr_pages_writ ...
- POJ 3991 Seinfeld
首先进行一次括号匹配,把正确匹配的全部删去. 删去之后剩下的状态肯定是 L个连续右括号+R个连续左括号. 如果L是偶数,答案是L/2+R/2: 否则答案是 (L-1)/2+(R-1)/2+2: #in ...
- [转]SQL Server® 2008 R2 Express 静默安装
1. http://msdn.itellyou.cn/下载Express版SQL Server 2.快捷键win+R,进入CMD,解压文件,解压命令为 <文件名>.exe /x <解 ...
- The account '...' is no team with ID '...'
iOS升到9.2之后,有一个大坑,原先真机调试的开发者账号(未付费),连不了Xcode了,会弹出一个提示框提示你, The account '...' is no team with ID '...' ...
- js实现从字符串中查找出现次数最多的字符的两种解决办法
方法一:正则表达式匹配 var str = "adadfdfseffserfefsefseeffffftsdg"; ; var result = ""; whi ...
- 字符串处理,NSNumber转换
more:http://www.superqq.com/blog/categories/ioskai-fa/ 1.判断字符串是否为空 if ([text lenght] == 0) { // ...
- LogBack log出力路径
转自:http://blog.csdn.net/z69183787/article/details/30284391 请看下面这段配置,这是无法工作的: <?xml version=" ...